+ {context => {
+ const { authList } = context;
+ return {authList[authKey] ? children : '无权限'}
;
+ }}
+
+ );
+ }
+}
+
+export default AuthorityControl;
From de8e545e5069d84e7050b1f5bf9a376b4f9438f2 Mon Sep 17 00:00:00 2001
From: sin <2943460818@qq.com>
Date: Thu, 28 Feb 2019 13:38:02 +0800
Subject: [PATCH 2/3] =?UTF-8?q?-=20=E6=B7=BB=E5=8A=A0=20global=20context?=
=?UTF-8?q?=EF=BC=8C=E6=9D=83=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/src/layouts/GlobalAuthorityContext.js | 9 +++++++++
1 file changed, 9 insertions(+)
create mode 100644 admin-web/src/layouts/GlobalAuthorityContext.js
diff --git a/admin-web/src/layouts/GlobalAuthorityContext.js b/admin-web/src/layouts/GlobalAuthorityContext.js
new file mode 100644
index 000000000..e0ee5ec51
--- /dev/null
+++ b/admin-web/src/layouts/GlobalAuthorityContext.js
@@ -0,0 +1,9 @@
+import React from 'react';
+
+// 创建全局的权限控制 context,方便在所有页面使用
+const GlobalAuthorityContext = React.createContext({
+ theme: 'dark',
+ toggle: () => {},
+});
+
+export default GlobalAuthorityContext;
From 60c2cad6e221b2dee991d94d5c4537bd16394f8f Mon Sep 17 00:00:00 2001
From: sin <2943460818@qq.com>
Date: Thu, 28 Feb 2019 13:46:33 +0800
Subject: [PATCH 3/3] =?UTF-8?q?-=20=E5=A2=9E=E5=8A=A0=20Home=20=E9=A1=B5?=
=?UTF-8?q?=E9=9D=A2=EF=BC=8C=E9=BB=98=E8=AE=A4=E9=87=8D=E5=AE=9A=E5=90=91?=
=?UTF-8?q?=E8=AF=8D=E9=A1=B5=E9=9D=A2?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
admin-web/config/router.config.js | 11 +++++++++--
admin-web/src/pages/Home/Home.js | 28 ++++++++++++++++++++++++++++
2 files changed, 37 insertions(+), 2 deletions(-)
create mode 100644 admin-web/src/pages/Home/Home.js
diff --git a/admin-web/config/router.config.js b/admin-web/config/router.config.js
index 429db6aa5..64a10f6c5 100644
--- a/admin-web/config/router.config.js
+++ b/admin-web/config/router.config.js
@@ -21,6 +21,15 @@ export default [
Routes: ['src/pages/Authorized'],
authority: ['admin', 'user'],
routes: [
+ // redirect
+ { path: '/', redirect: '/home' },
+ // home
+ {
+ path: '/home',
+ name: 'home',
+ icon: 'user',
+ component: './Home/Home',
+ },
// admin
{
path: '/admin',
@@ -34,8 +43,6 @@ export default [
},
],
},
- // dashboard
- { path: '/', redirect: '/dashboard/analysis' },
{
path: '/dashboard',
name: 'dashboard',
diff --git a/admin-web/src/pages/Home/Home.js b/admin-web/src/pages/Home/Home.js
new file mode 100644
index 000000000..f334d7ebb
--- /dev/null
+++ b/admin-web/src/pages/Home/Home.js
@@ -0,0 +1,28 @@
+import React, { Component } from 'react';
+import { Button } from 'antd';
+import AuthorityControl from '../../components/AuthorityControl';
+import GlobalAuthority from '../../layouts/GlobalAuthorityContext';
+
+export default class Home extends Component {
+ state = {};
+
+ render() {
+ // 定义认证的属性 TODO
+ const GlobalAuthorityProps = {
+ user: 'admin',
+ login: 'success',
+ authList: {
+ 'auth.button': true,
+ },
+ };
+
+ return (
+