fix: 修复后端返回路由数据中 children 为空数组导致菜单无法正常生成

This commit is contained in:
Hooray Hu
2024-05-14 10:14:30 +08:00
parent e6265a7c64
commit e023671bac
+3 -2
View File
@@ -163,11 +163,12 @@ const useMenuStore = defineStore(
menus.forEach((menu) => {
if (hasPermission(permissions, menu)) {
const tmpMenu = cloneDeep(menu)
if (tmpMenu.children) {
if (tmpMenu.children && tmpMenu.children.length > 0) {
tmpMenu.children = filterAsyncMenus(tmpMenu.children, permissions) as Menu.recordRaw[]
tmpMenu.children.length && res.push(tmpMenu)
tmpMenu.children.length > 0 && res.push(tmpMenu)
}
else {
delete tmpMenu.children
res.push(tmpMenu)
}
}