🐛 修复动态获取角色的bug
This commit is contained in:
parent
b2b0893b78
commit
433ac0b163
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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(),
|
||||
};
|
||||
21
src/app.js
21
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();
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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',
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user