JinZHouXiYiJi_DaPin2/docs/Content/menus.ts

19 lines
500 B
TypeScript
Raw Permalink Normal View History

2023-12-05 13:23:01 +08:00
import type { AppRouteRecordRaw } from '@/router/types'
import type { MenuItem } from '../modules/components/SiderContent'
export const getMenus = (routers: AppRouteRecordRaw[]): Array<MenuItem> => {
return routers.map((el) => {
const item = {
label: el.meta.title,
icon: el.meta.icon!,
key: el.name,
children: [] as Array<MenuItem>
}
if (el.children && el.children?.length > 0) {
item.children = getMenus(el.children || [])
}
return item
})
}