Skip to content

Commit

Permalink
close page permission control
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaohuoni committed Mar 25, 2019
1 parent 07aa804 commit 7e28c7f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 38 deletions.
5 changes: 1 addition & 4 deletions config/router.config.js
Expand Up @@ -21,10 +21,9 @@ export default [
{
path: '/',
component: '../layouts/BasicLayout',
Routes: ['src/pages/Authorized'],
routes: [
// dashboard
{ path: '/', redirect: '/dashboard/analysis', authority: ['admin', 'user'] },
{ path: '/', redirect: '/dashboard/analysis' },
{
path: '/dashboard',
name: 'dashboard',
Expand Down Expand Up @@ -88,7 +87,6 @@ export default [
{
path: '/form/advanced-form',
name: 'advancedform',
authority: ['admin'],
component: './Forms/AdvancedForm',
},
],
Expand Down Expand Up @@ -162,7 +160,6 @@ export default [
{
path: '/profile/advanced',
name: 'advanced',
authority: ['admin'],
component: './Profile/AdvancedProfile',
},
],
Expand Down
35 changes: 1 addition & 34 deletions src/app.js
@@ -1,5 +1,3 @@
import fetch from 'dva/fetch';

export const dva = {
config: {
onError(err) {
Expand All @@ -8,37 +6,6 @@ export const dva = {
},
};

let authRoutes = {};

function ergodicRoutes(routes, authKey, authority) {
routes.forEach(element => {
if (element.path === authKey) {
if (!element.authority) element.authority = []; // eslint-disable-line
Object.assign(element.authority, authority || []);
} else if (element.routes) {
ergodicRoutes(element.routes, authKey, authority);
}
return element;
});
}

export function patchRoutes(routes) {
Object.keys(authRoutes).map(authKey =>
ergodicRoutes(routes, authKey, authRoutes[authKey].authority)
);
window.g_routes = routes;
}

export function render(oldRender) {
fetch('/api/auth_routes')
.then(res => res.json())
.then(
ret => {
authRoutes = ret;
oldRender();
},
() => {
oldRender();
}
);
oldRender();
}

0 comments on commit 7e28c7f

Please sign in to comment.