diff --git a/config/router.config.js b/config/router.config.js index 291d5d0f151117429b701c7cbf4a0ba1410760b0..20785023552f726c8be503bde0a92999949940cc 100644 --- a/config/router.config.js +++ b/config/router.config.js @@ -14,6 +14,7 @@ module.exports = [ { path: '/', component: '../layouts/BasicLayout', + Routes: ['src/pages/Authorized'], routes: [ // dashboard { path: '/', redirect: '/dashboard/analysis' }, @@ -22,7 +23,12 @@ module.exports = [ name: 'dashboard', icon: 'dashboard', routes: [ - { path: '/dashboard/analysis', name: 'analysis', component: './Dashboard/Analysis' }, + { + path: '/dashboard/analysis', + authority: ['admin'], + name: 'analysis', + component: './Dashboard/Analysis', + }, { path: '/dashboard/monitor', name: 'monitor', component: './Dashboard/Monitor' }, { path: '/dashboard/workplace', name: 'workplace', component: './Dashboard/Workplace' }, ], diff --git a/package.json b/package.json index 4d6edea25623c536aa828236c814cd595bbb3d62..882d405a6cd601dc4dcf67bd644ded4aef5091bc 100755 --- a/package.json +++ b/package.json @@ -48,6 +48,7 @@ "react-document-title": "^2.0.3", "react-dom": "^16.4.2", "react-fittext": "^1.0.0", + "react-router-config": "^1.0.0-beta.4", "react-router-dom": "^4.3.1", "umi": "^2.0.0-beta.10" }, diff --git a/src/pages/Authorized.js b/src/pages/Authorized.js new file mode 100644 index 0000000000000000000000000000000000000000..625f8206d98e162bf66a3404f2e430bd444f3e75 --- /dev/null +++ b/src/pages/Authorized.js @@ -0,0 +1,18 @@ +import React from 'react'; +import RenderAuthorized from '@/components/Authorized'; +import Exception from '@/components/Exception'; +import { matchRoutes } from 'react-router-config'; + +const Authorized = RenderAuthorized('user'); +const noMatch = ; + +export default ({ children, route, location }) => { + const branch = + matchRoutes(route.routes, location.pathname).filter(item => item.match.isExact)[0] || {}; + const { authority } = branch.route || {}; + return ( + + {children} + + ); +}; diff --git a/src/pages/Dashboard/Monitor.js b/src/pages/Dashboard/Monitor.js index 5709ca0af86bebcec7d9ee17b28725c4edbf3bc6..fbbdb7bb1143b21351a8e8be08a897900e363fff 100644 --- a/src/pages/Dashboard/Monitor.js +++ b/src/pages/Dashboard/Monitor.js @@ -18,7 +18,7 @@ const targetTime = new Date().getTime() + 3900000; // use permission as a parameter const havePermissionAsync = new Promise(resolve => { // Call resolve on behalf of passed - setTimeout(() => resolve(), 1000); + setTimeout(() => resolve(), 100); }); @Secured(havePermissionAsync) @connect(({ monitor, loading }) => ({