forked from AkkomaGang/admin-fe
add promise
This commit is contained in:
parent
faea4d8bf6
commit
523a9b3de3
1 changed files with 21 additions and 18 deletions
|
@ -24,25 +24,28 @@ const permission = {
|
|||
actions: {
|
||||
// s
|
||||
GenerateRoutes({ commit }, data) {
|
||||
const { roles } = data;
|
||||
const accessedRouters = asyncRouterMap.filter(v => {
|
||||
if (roles.indexOf('admin') >= 0) return true;
|
||||
if (hasPermission(roles, v)) {
|
||||
if (v.children && v.children.length > 0) {
|
||||
v.children = v.children.filter(child => {
|
||||
if (hasPermission(roles, child)) {
|
||||
return child
|
||||
}
|
||||
return false;
|
||||
});
|
||||
return v
|
||||
} else {
|
||||
return v
|
||||
return new Promise(resolve => {
|
||||
const { roles } = data;
|
||||
const accessedRouters = asyncRouterMap.filter(v => {
|
||||
if (roles.indexOf('admin') >= 0) return true;
|
||||
if (hasPermission(roles, v)) {
|
||||
if (v.children && v.children.length > 0) {
|
||||
v.children = v.children.filter(child => {
|
||||
if (hasPermission(roles, child)) {
|
||||
return child
|
||||
}
|
||||
return false;
|
||||
});
|
||||
return v
|
||||
} else {
|
||||
return v
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
});
|
||||
commit('SET_ROUTERS', accessedRouters);
|
||||
return false;
|
||||
});
|
||||
commit('SET_ROUTERS', accessedRouters);
|
||||
resolve();
|
||||
})
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue