Skip to content

Commit e84d87d

Browse files
committed
fix: 🐛 (route)修复父级菜单 alwaysShow 无效问题
- 修改 processRoutes 函数,如果 children 为 undefined,则原样返回
1 parent 0323ca3 commit e84d87d

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/store/modules/permission-store.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ export const usePermissionStore = defineStore("permission", () => {
2121
async function generateRoutes(): Promise<RouteRecordRaw[]> {
2222
try {
2323
const data = await MenuAPI.getRoutes(); // 获取当前登录人拥有的菜单路由
24-
const dynamicRoutes = parseDynamicRoutes(processRoutes(data));
24+
const processRouteList = processRoutes(data); // 处理后的路由数据
25+
const dynamicRoutes = parseDynamicRoutes(processRouteList);
2526

2627
routes.value = [...constantRoutes, ...dynamicRoutes];
2728

@@ -117,8 +118,8 @@ const processRoutes = (routes: RouteVO[], isTopLevel: boolean = true): RouteVO[]
117118
return {
118119
...args,
119120
component: isTopLevel || component !== "Layout" ? component : undefined,
120-
// 递归处理children,标记为非顶层
121-
children: children && children.length > 0 ? processRoutes(children, false) : [],
121+
// 递归处理children,标记为非顶层 todo 原样返回 children(undefined)
122+
children: children && children.length > 0 ? processRoutes(children, false) : children,
122123
};
123124
});
124125
};

0 commit comments

Comments
 (0)