diff --git a/src/app.js b/src/app.js index 7de5a69e1330e9ff0738ddd1ce378cc661e04619..0f35ff9af6376bcc3c3606f219ae6bcd1af6b769 100644 --- a/src/app.js +++ b/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(); + } + ); }