🐛 修复动态获取角色的bug

This commit is contained in:
smallchill 2019-01-21 16:08:04 +08:00
parent b2b0893b78
commit 433ac0b163
4 changed files with 20 additions and 25 deletions

View File

@ -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,

View File

@ -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(),
};

View File

@ -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();
});
}

View File

@ -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',