mirror of
https://github.com/vbenjs/vue-vben-admin.git
synced 2025-08-27 14:49:43 +08:00
perf: the routeModule can ignore the layou configuration without writing
This commit is contained in:
@@ -49,8 +49,12 @@ export function transformRouteToMenu(routeModList: AppRouteModule[]) {
|
||||
const routeList: AppRouteRecordRaw[] = [];
|
||||
cloneRouteModList.forEach((item) => {
|
||||
const { layout, routes } = item;
|
||||
layout.children = routes;
|
||||
routeList.push(layout);
|
||||
if (layout) {
|
||||
layout.children = routes;
|
||||
routeList.push(layout);
|
||||
} else {
|
||||
routeList.push(...routes);
|
||||
}
|
||||
});
|
||||
return treeMap(routeList, {
|
||||
conversion: (node: AppRouteRecordRaw) => {
|
||||
|
@@ -23,18 +23,24 @@ export function genRouteModule(moduleList: AppRouteModule[]) {
|
||||
for (const routeMod of moduleList) {
|
||||
const routes = routeMod.routes as any;
|
||||
const layout = routeMod.layout;
|
||||
let router = createRouter({ routes, history: createWebHashHistory() });
|
||||
const router = createRouter({ routes, history: createWebHashHistory() });
|
||||
|
||||
const flatList = toRaw(router.getRoutes()).filter((item) => item.children.length === 0);
|
||||
const flatList = (toRaw(router.getRoutes()).filter(
|
||||
(item) => item.children.length === 0
|
||||
) as unknown) as AppRouteRecordRaw[];
|
||||
try {
|
||||
(router as any) = null;
|
||||
} catch (error) {}
|
||||
|
||||
flatList.forEach((item) => {
|
||||
item.path = `${layout.path}${item.path}`;
|
||||
item.path = `${layout ? layout.path : ''}${item.path}`;
|
||||
});
|
||||
layout.children = (flatList as unknown) as AppRouteRecordRaw[];
|
||||
ret.push(layout);
|
||||
if (layout) {
|
||||
layout.children = flatList;
|
||||
ret.push(layout);
|
||||
} else {
|
||||
ret.push(...flatList);
|
||||
}
|
||||
}
|
||||
return ret as RouteRecordRaw[];
|
||||
}
|
||||
|
Reference in New Issue
Block a user