From 21bacc19d8a3141783dbf376c6aaea5a270fc379 Mon Sep 17 00:00:00 2001 From: sin <2943460818@qq.com> Date: Fri, 1 Mar 2019 18:15:12 +0800 Subject: [PATCH] =?UTF-8?q?-=20=E6=B7=BB=E5=8A=A0=E8=8F=9C=E5=8D=95?= =?UTF-8?q?=E6=9D=83=E9=99=90=E6=8E=A7=E5=88=B6=20-=20url=20=E6=9D=83?= =?UTF-8?q?=E9=99=90=E6=8E=A7=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- admin-web/mock/admin.js | 21 +++++++ admin-web/mock/geographic/admin-menu-all.json | 5 ++ admin-web/mock/geographic/admin-menu.json | 26 ++++++++ admin-web/mock/geographic/admin-urls.json | 5 ++ .../src/components/AuthorityControl/index.js | 6 +- admin-web/src/components/SiderMenu/index.js | 1 + admin-web/src/layouts/BasicLayout.js | 15 ++++- .../src/layouts/GlobalAuthorityContext.js | 9 --- admin-web/src/layouts/UrlsContext.js | 6 ++ admin-web/src/models/{menu.js => menu.jsx} | 62 +++++++++++++++++-- admin-web/src/pages/Home/Home.js | 6 +- admin-web/src/services/admin.js | 10 +++ admin-web/src/utils/request.js | 7 ++- admin-web/笔记 | 4 ++ 14 files changed, 160 insertions(+), 23 deletions(-) create mode 100644 admin-web/mock/admin.js create mode 100644 admin-web/mock/geographic/admin-menu-all.json create mode 100644 admin-web/mock/geographic/admin-menu.json create mode 100644 admin-web/mock/geographic/admin-urls.json delete mode 100644 admin-web/src/layouts/GlobalAuthorityContext.js create mode 100644 admin-web/src/layouts/UrlsContext.js rename admin-web/src/models/{menu.js => menu.jsx} (62%) create mode 100644 admin-web/src/services/admin.js create mode 100644 admin-web/笔记 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}