From 433ac0b163fc2511b4e980dc04186d4b9b947f12 Mon Sep 17 00:00:00 2001 From: smallchill Date: Mon, 21 Jan 2019 16:08:04 +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/role.js | 9 +++++++++ mock/route.js | 11 ----------- src/app.js | 21 +++++++-------------- src/services/role.js | 4 ++++ 4 files changed, 20 insertions(+), 25 deletions(-) delete mode 100644 mock/route.js diff --git a/mock/role.js b/mock/role.js index 96e80e1..d5d05ec 100644 --- a/mock/role.js +++ b/mock/role.js @@ -83,6 +83,14 @@ function getFakeTree(req, res) { return res.json(json); } +function getFakeRoutes(req, res) { + const json = { code: 200, success: true, msg: '操作成功' }; + json.data = { + '/form/advanced-form': { authority: ['admin', 'user'] }, + }; + return res.json(json); +} + function fakeSuccess(req, res) { const json = { code: 200, success: true, msg: '操作成功' }; return res.json(json); @@ -92,6 +100,7 @@ const proxy = { 'GET /api/blade-system/role/list': getFakeList, 'GET /api/blade-system/role/detail': getFakeDetail, 'GET /api/blade-system/role/tree': getFakeTree, + 'GET /api/blade-system/role/auth-routes': getFakeRoutes, 'POST /api/blade-system/role/submit': fakeSuccess, 'POST /api/blade-system/role/remove': fakeSuccess, 'POST /api/blade-system/role/grant': fakeSuccess, diff --git a/mock/route.js b/mock/route.js deleted file mode 100644 index 3a8bc51..0000000 --- a/mock/route.js +++ /dev/null @@ -1,11 +0,0 @@ -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 5b8f7f7..27ff35d 100644 --- a/src/app.js +++ b/src/app.js @@ -1,4 +1,4 @@ -import fetch from 'dva/fetch'; +import { routesAuthority } from './services/role'; export const dva = { config: { @@ -32,17 +32,10 @@ export function patchRoutes(routes) { } export function render(oldRender) { - fetch('/api/auth_routes') - .then(res => res.json()) - .then( - ret => { - if (ret.code === 200) { - authRoutes = ret.data; - } - oldRender(); - }, - () => { - oldRender(); - } - ); + routesAuthority().then(response => { + if (response) { + authRoutes = response.data; + } + oldRender(); + }); } diff --git a/src/services/role.js b/src/services/role.js index e1cd02d..2cdfcaf 100644 --- a/src/services/role.js +++ b/src/services/role.js @@ -12,6 +12,10 @@ export async function tree(params) { return request(`/api/blade-system/role/tree?${stringify(params)}`); } +export async function routesAuthority() { + return request('/api/blade-system/role/auth-routes'); +} + export async function grant(params) { return request('/api/blade-system/role/grant', { method: 'POST',