diff --git a/mock/route.js b/mock/route.js index 418d10f..3a8bc51 100644 --- a/mock/route.js +++ b/mock/route.js @@ -1,5 +1,11 @@ -export default { - '/api/auth_routes': { +function getFakeRoutes(req, res) { + const json = { code: 200, success: true, msg: '操作成功' }; + json.data = { '/form/advanced-form': { authority: ['admin', 'user'] }, - }, + }; + return res.json(json); +} + +export default { + '/api/auth_routes': getFakeRoutes(), }; diff --git a/src/app.js b/src/app.js index 0f35ff9..5b8f7f7 100644 --- a/src/app.js +++ b/src/app.js @@ -8,7 +8,9 @@ export const dva = { }, }; -let authRoutes = {}; +let authRoutes = { + '/form/advanced-form': { authority: ['admin', 'user'] }, +}; function ergodicRoutes(routes, authKey, authority) { routes.forEach(element => { @@ -34,7 +36,9 @@ export function render(oldRender) { .then(res => res.json()) .then( ret => { - authRoutes = ret; + if (ret.code === 200) { + authRoutes = ret.data; + } oldRender(); }, () => {