foreign-admin-ui/src/router/handleRouter.ts

24 lines
634 B
TypeScript

const viewModules = import.meta.glob('@/views/**/index.vue')
export const handleRouter = (list: any[]):any[] => {
let routerList:any[] = [];
list.forEach(item => {
if (item.son && item.son.length > 0) {
routerList.push(...handleRouter(item.son))
} else {
const componentPath = `/src/views${item.path}/index.vue`
routerList.push({
path: item.path,
name: item.name,
component: viewModules[componentPath] || (() => import('@/views/404/index.vue')),
meta: {
title: item.name, // 左侧菜单显示的标题
},
})
}
});
return routerList;
};