修正消息中心不显示
This commit is contained in:
@@ -161,14 +161,41 @@ function generateRouteFromMenu(menu: SysMenu, isTopLevel = true): RouteRecordRaw
|
||||
}
|
||||
|
||||
// 处理子路由
|
||||
if (layout && LAYOUT_MAP[layout] && !hasChildren && menu.component && isTopLevel) {
|
||||
// 如果指定了布局但没有子菜单,将页面组件作为子路由
|
||||
if (layout && LAYOUT_MAP[layout] && menu.component && isTopLevel) {
|
||||
// 如果指定了布局,将页面组件作为子路由
|
||||
route.children = [{
|
||||
path: '',
|
||||
name: `${menu.menuID}_page`,
|
||||
component: getComponent(menu.component),
|
||||
meta: route.meta
|
||||
}];
|
||||
|
||||
// 如果还有其他子菜单,继续添加
|
||||
if (hasChildren) {
|
||||
const pageChildren: SysMenu[] = [];
|
||||
const normalChildren: SysMenu[] = [];
|
||||
|
||||
menu.children!.forEach(child => {
|
||||
if (child.type === MenuType.PAGE) {
|
||||
pageChildren.push(child);
|
||||
} else {
|
||||
normalChildren.push(child);
|
||||
}
|
||||
});
|
||||
|
||||
// 添加普通子菜单
|
||||
normalChildren.forEach(child => {
|
||||
const childRoute = generateRouteFromMenu(child, false);
|
||||
if (childRoute) {
|
||||
route.children!.push(childRoute);
|
||||
}
|
||||
});
|
||||
|
||||
// PAGE 类型的菜单保存到 meta
|
||||
if (pageChildren.length > 0) {
|
||||
route.meta.pageChildren = pageChildren;
|
||||
}
|
||||
}
|
||||
} else if (hasChildren) {
|
||||
// 处理有子菜单的情况
|
||||
route.children = [];
|
||||
@@ -290,6 +317,11 @@ function getComponent(componentName: string) {
|
||||
return module;
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('[路由生成] 组件加载失败:', {
|
||||
原始组件名: componentName,
|
||||
最终路径: componentPath,
|
||||
错误: error
|
||||
});
|
||||
// 返回404组件
|
||||
return import('@/views/public/error/404.vue').catch(() =>
|
||||
Promise.resolve({
|
||||
|
||||
Reference in New Issue
Block a user