Переглянути джерело

close page permission control (#3842)

陈小聪 6 роки тому
батько
коміт
e8c8f8b90d
2 змінених файлів з 2 додано та 38 видалено
  1. 1 4
      config/router.config.js
  2. 1 34
      src/app.js

+ 1 - 4
config/router.config.js

@@ -21,10 +21,9 @@ export default [
   {
   {
     path: '/',
     path: '/',
     component: '../layouts/BasicLayout',
     component: '../layouts/BasicLayout',
-    Routes: ['src/pages/Authorized'],
     routes: [
     routes: [
       // dashboard
       // dashboard
-      { path: '/', redirect: '/dashboard/analysis', authority: ['admin', 'user'] },
+      { path: '/', redirect: '/dashboard/analysis' },
       {
       {
         path: '/dashboard',
         path: '/dashboard',
         name: 'dashboard',
         name: 'dashboard',
@@ -88,7 +87,6 @@ export default [
           {
           {
             path: '/form/advanced-form',
             path: '/form/advanced-form',
             name: 'advancedform',
             name: 'advancedform',
-            authority: ['admin'],
             component: './Forms/AdvancedForm',
             component: './Forms/AdvancedForm',
           },
           },
         ],
         ],
@@ -162,7 +160,6 @@ export default [
           {
           {
             path: '/profile/advanced',
             path: '/profile/advanced',
             name: 'advanced',
             name: 'advanced',
-            authority: ['admin'],
             component: './Profile/AdvancedProfile',
             component: './Profile/AdvancedProfile',
           },
           },
         ],
         ],

+ 1 - 34
src/app.js

@@ -1,5 +1,3 @@
-import fetch from 'dva/fetch';
-
 export const dva = {
 export const dva = {
   config: {
   config: {
     onError(err) {
     onError(err) {
@@ -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) {
 export function render(oldRender) {
-  fetch('/api/auth_routes')
-    .then(res => res.json())
-    .then(
-      ret => {
-        authRoutes = ret;
-        oldRender();
-      },
-      () => {
-        oldRender();
-      }
-    );
+  oldRender();
 }
 }