diff --git a/config/router.config.js b/config/router.config.js
index cb6fd5f1f1fca0191aa5fa6f650658bde07875c8..bef1be3819b891dae2f1401befee5d42569b9dda 100644
--- a/config/router.config.js
+++ b/config/router.config.js
@@ -15,6 +15,7 @@ export default [
path: '/',
component: '../layouts/BasicLayout',
Routes: ['src/pages/Authorized'],
+ authority: ['admin', 'user'],
routes: [
// dashboard
{ path: '/', redirect: '/dashboard/analysis' },
@@ -82,6 +83,7 @@ export default [
{
path: '/form/advanced-form',
name: 'advancedform',
+ authority: ['admin'],
component: './Forms/AdvancedForm',
},
],
@@ -149,6 +151,7 @@ export default [
{
path: '/profile/advanced',
name: 'advanced',
+ authority: ['admin'],
component: './Profile/AdvancedProfile',
},
],
diff --git a/src/components/GlobalHeader/RightContent.js b/src/components/GlobalHeader/RightContent.js
index 3c882b9f36b40c51d13bbcf36124a7313b63ec3e..12d69516f53facd3676fcf0efb35b26826624575 100644
--- a/src/components/GlobalHeader/RightContent.js
+++ b/src/components/GlobalHeader/RightContent.js
@@ -74,7 +74,7 @@ export default class GlobalHeaderRight extends PureComponent {
- 退出登录
+
);
diff --git a/src/locales/en-US.js b/src/locales/en-US.js
index 729836ec0a79440fa461af63171cb9fd7b7f920a..c0a7c5eefe1f55350d6a1d31e5582607b6a366a4 100644
--- a/src/locales/en-US.js
+++ b/src/locales/en-US.js
@@ -35,6 +35,7 @@ export default {
'menu.account.center': 'Account Center',
'menu.account.settings': 'Account Settings',
'menu.account.trigger': 'Trigger Error',
+ 'menu.account.logout': 'Logout',
'app.home.introduce': 'introduce',
'app.analysis.test': 'Gongzhuan No.{no} shop',
'app.analysis.introduce': 'Introduce',
diff --git a/src/locales/zh-CN.js b/src/locales/zh-CN.js
index 81d766a684989fb06e6979e2e9e64a598fb10ac3..7c6f363243f035d995c24dd171d3ed15ba7621c5 100644
--- a/src/locales/zh-CN.js
+++ b/src/locales/zh-CN.js
@@ -37,6 +37,7 @@ export default {
'menu.account.center': '个人中心',
'menu.account.settings': '个人设置',
'menu.account.trigger': '触发报错',
+ 'menu.account.logout': '退出登录',
'app.home.introduce': '介绍',
'app.analysis.test': '工专路 {no} 号店',
'app.analysis.introduce': '指标说明',
diff --git a/src/pages/Authorized.js b/src/pages/Authorized.js
index e0e18d7036e0fccee6ce33ad6b49e9ca7cf7626b..238888a7bc750647e1fb25aaec763e7782eb03b7 100644
--- a/src/pages/Authorized.js
+++ b/src/pages/Authorized.js
@@ -2,24 +2,15 @@ import React from 'react';
import RenderAuthorized from '@/components/Authorized';
import Exception from '@/components/Exception';
import { getAuthority } from '@/utils/authority';
-import { matchRoutes } from 'react-router-config';
-import intersection from 'lodash/intersection';
import { formatMessage } from 'umi/locale';
import Link from 'umi/link';
+import Redirect from 'umi/redirect';
-const Authorized = RenderAuthorized(getAuthority());
+const Authority = getAuthority();
+const Authorized = RenderAuthorized(Authority);
-export default ({ children, route, location }) => {
- const routes = matchRoutes(route.routes, location.pathname);
- const authorities = [];
- routes.forEach(item => {
- if (Array.isArray(item.route.authority) && item.route.authority.length) {
- authorities.push(item.route.authority);
- } else if (typeof item.route.authority === 'string' && item.route.authority) {
- authorities.push([item.route.authority]);
- }
- });
- const noMatch = (
+export default ({ children }) => {
+ let noMatch = (
{
backText={formatMessage({ id: 'app.exception.back' })}
/>
);
+ // if Authority === ['guest'] redirect to /user/login
+ // You can implement the logic here.
+ if (Authority.join('') === 'guest') {
+ noMatch = ;
+ }
return (
-
+
{children}
);