mirror of
https://github.com/iczer/vue-antd-admin
synced 2025-04-05 19:41:37 +08:00
修复:更改角色后菜单不能正确显示的问题;#179
fix: the menu does not display correctly after changing roles;
This commit is contained in:
parent
83c6381a4b
commit
2fc5b9d594
@ -25,7 +25,7 @@ export default {
|
|||||||
menuData(state, getters, rootState) {
|
menuData(state, getters, rootState) {
|
||||||
if (state.filterMenu) {
|
if (state.filterMenu) {
|
||||||
const {permissions, roles} = rootState.account
|
const {permissions, roles} = rootState.account
|
||||||
filterMenu(state.menuData, permissions, roles)
|
state.menuData = filterMenu(state.menuData, permissions, roles)
|
||||||
}
|
}
|
||||||
return state.menuData
|
return state.menuData
|
||||||
},
|
},
|
||||||
|
@ -69,15 +69,16 @@ function hasAuthority(route, permissions, roles) {
|
|||||||
* @param roles
|
* @param roles
|
||||||
*/
|
*/
|
||||||
function filterMenu(menuData, permissions, roles) {
|
function filterMenu(menuData, permissions, roles) {
|
||||||
menuData.forEach(menu => {
|
return menuData.filter(menu => {
|
||||||
if (menu.meta && menu.meta.invisible === undefined) {
|
if (menu.meta && menu.meta.invisible === undefined) {
|
||||||
if (!hasAuthority(menu, permissions, roles)) {
|
if (!hasAuthority(menu, permissions, roles)) {
|
||||||
menu.meta.invisible = true
|
return false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (menu.children && menu.children.length > 0) {
|
if (menu.children && menu.children.length > 0) {
|
||||||
filterMenu(menu.children, permissions, roles)
|
menu.children = filterMenu(menu.children, permissions, roles)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
return true
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user