mirror of
https://gitee.com/fantastic-admin/basic.git
synced 2024-12-01 19:48:15 +08:00
fix: 修复主导航 children 为空时报错
This commit is contained in:
parent
57fcd2785c
commit
9e444c83f8
@ -23,24 +23,26 @@ const useMenuStore = defineStore(
|
||||
function convertRouteToMenu(routes: Route.recordMainRaw[]): Menu.recordMainRaw[] {
|
||||
const returnMenus: Menu.recordMainRaw[] = []
|
||||
routes.forEach((item) => {
|
||||
if (settingsStore.settings.menu.mode === 'single') {
|
||||
returnMenus.length === 0 && returnMenus.push({
|
||||
meta: {},
|
||||
children: [],
|
||||
})
|
||||
returnMenus[0].children.push(...convertRouteToMenuRecursive(item.children))
|
||||
}
|
||||
else {
|
||||
const menuItem: Menu.recordMainRaw = {
|
||||
meta: {
|
||||
title: item?.meta?.title,
|
||||
icon: item?.meta?.icon,
|
||||
auth: item?.meta?.auth,
|
||||
},
|
||||
children: [],
|
||||
if (item.children.length > 0) {
|
||||
if (settingsStore.settings.menu.mode === 'single') {
|
||||
returnMenus.length === 0 && returnMenus.push({
|
||||
meta: {},
|
||||
children: [],
|
||||
})
|
||||
returnMenus[0].children.push(...convertRouteToMenuRecursive(item.children))
|
||||
}
|
||||
else {
|
||||
const menuItem: Menu.recordMainRaw = {
|
||||
meta: {
|
||||
title: item?.meta?.title,
|
||||
icon: item?.meta?.icon,
|
||||
auth: item?.meta?.auth,
|
||||
},
|
||||
children: [],
|
||||
}
|
||||
menuItem.children = convertRouteToMenuRecursive(item.children)
|
||||
returnMenus.push(menuItem)
|
||||
}
|
||||
menuItem.children = convertRouteToMenuRecursive(item.children)
|
||||
returnMenus.push(menuItem)
|
||||
}
|
||||
})
|
||||
return returnMenus
|
||||
|
Loading…
Reference in New Issue
Block a user