Jelajahi Sumber

fix: error-processing-request (#3402)

* Close: #3398

* error authority is undefined
陈小聪 7 tahun lalu
induk
melakukan
5a9d3c079c
1 mengubah file dengan 11 tambahan dan 5 penghapusan
  1. 11 5
      src/app.js

+ 11 - 5
src/app.js

@@ -8,11 +8,12 @@ export const dva = {
   },
 };
 
-let authRoutes = null;
+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);
@@ -31,8 +32,13 @@ export function patchRoutes(routes) {
 export function render(oldRender) {
   fetch('/api/auth_routes')
     .then(res => res.json())
-    .then(ret => {
-      authRoutes = ret;
-      oldRender();
-    });
+    .then(
+      ret => {
+        authRoutes = ret;
+        oldRender();
+      },
+      () => {
+        oldRender();
+      }
+    );
 }