From b2b0893b786b7f7b872ab63793783e37e56b6f2e Mon Sep 17 00:00:00 2001 From: smallchill Date: Mon, 21 Jan 2019 15:52:43 +0800 Subject: [PATCH] =?UTF-8?q?:bug:=20=E4=BF=AE=E5=A4=8D=E5=8A=A8=E6=80=81?= =?UTF-8?q?=E8=8E=B7=E5=8F=96=E8=A7=92=E8=89=B2=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mock/route.js | 12 +++++++++--- src/app.js | 8 ++++++-- 2 files changed, 15 insertions(+), 5 deletions(-) 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(); }, () => {