diff --git a/admin-web/mock/admin.js b/admin-web/mock/admin.js new file mode 100644 index 000000000..1a201cff3 --- /dev/null +++ b/admin-web/mock/admin.js @@ -0,0 +1,21 @@ +import adminMenu from './geographic/admin-menu.json'; +import adminMenuAll from './geographic/admin-menu-all.json'; +import adminUrls from './geographic/admin-urls'; + +/* eslint-disable */ +function getAdminMenu(req, res) { + return res.json(adminMenu); +} + +function getAdminMenuAll(req, res) { + return res.json(adminMenuAll); +} + +function getAdminUrls(req, res) { + return res.json(adminUrls); +} + +export default { + 'GET /admin-api/admin/resource/admin_menu_tree': getAdminMenuAll, + 'GET /admin-api/admin/resource/admin_url_list': getAdminUrls, +}; diff --git a/admin-web/mock/geographic/admin-menu-all.json b/admin-web/mock/geographic/admin-menu-all.json new file mode 100644 index 000000000..e3329c0af --- /dev/null +++ b/admin-web/mock/geographic/admin-menu-all.json @@ -0,0 +1,5 @@ +{ + "code": 0, + "message": "", + "data": "all" +} diff --git a/admin-web/mock/geographic/admin-menu.json b/admin-web/mock/geographic/admin-menu.json new file mode 100644 index 000000000..ac5db246e --- /dev/null +++ b/admin-web/mock/geographic/admin-menu.json @@ -0,0 +1,26 @@ +{ + "code": 0, + "message": "", + "data": [ + { + "children": [ + { + "handler": "/order/list1", + "id": 1, + "name": "商品管理1", + "pid": 1 + }, + { + "handler": "/order/list2", + "id": 1, + "name": "商品管理2", + "pid": 1 + } + ], + "handler": "/home", + "id": 1, + "name": "商品管理", + "pid": 1 + } + ] +} diff --git a/admin-web/mock/geographic/admin-urls.json b/admin-web/mock/geographic/admin-urls.json new file mode 100644 index 000000000..7b89eeb09 --- /dev/null +++ b/admin-web/mock/geographic/admin-urls.json @@ -0,0 +1,5 @@ +{ + "code": 0, + "data": ["/admin/source/add", "/admin/source/delete"], + "message": "string" +} diff --git a/admin-web/src/components/AuthorityControl/index.js b/admin-web/src/components/AuthorityControl/index.js index 0fa6eec89..107aad504 100644 --- a/admin-web/src/components/AuthorityControl/index.js +++ b/admin-web/src/components/AuthorityControl/index.js @@ -1,17 +1,17 @@ import React, { PureComponent } from 'react'; -import GlobalAuthority from '../../layouts/GlobalAuthorityContext'; +import UrlsContext from '../../layouts/UrlsContext'; // 用于控制权限 class AuthorityControl extends PureComponent { render() { const { authKey, children } = this.props; return ( - + {context => { const { authList } = context; return
{authList[authKey] ? children : '无权限'}
; }} -
+ ); } } diff --git a/admin-web/src/components/SiderMenu/index.js b/admin-web/src/components/SiderMenu/index.js index 0be273314..58ce4b457 100644 --- a/admin-web/src/components/SiderMenu/index.js +++ b/admin-web/src/components/SiderMenu/index.js @@ -6,6 +6,7 @@ import { getFlatMenuKeys } from './SiderMenuUtils'; const SiderMenuWrapper = React.memo(props => { const { isMobile, menuData, collapsed, onCollapse } = props; const flatMenuKeys = getFlatMenuKeys(menuData); + return isMobile ? ( { const routes = routeData.slice(); // clone @@ -166,7 +178,7 @@ class BasicLayout extends React.Component { /> }> - {children} + {children}