From e84d87d403a732d1a6036b9633707685987c44c0 Mon Sep 17 00:00:00 2001 From: zimo493 <2081182432@qq.com> Date: Mon, 8 Sep 2025 09:09:17 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20:bug:=20(route)=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E7=88=B6=E7=BA=A7=E8=8F=9C=E5=8D=95=20`alwaysShow`=20=E6=97=A0?= =?UTF-8?q?=E6=95=88=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 修改 processRoutes 函数,如果 children 为 undefined,则原样返回 --- src/store/modules/permission-store.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/store/modules/permission-store.ts b/src/store/modules/permission-store.ts index b980176d..a4088f7f 100644 --- a/src/store/modules/permission-store.ts +++ b/src/store/modules/permission-store.ts @@ -21,7 +21,8 @@ export const usePermissionStore = defineStore("permission", () => { async function generateRoutes(): Promise { try { const data = await MenuAPI.getRoutes(); // 获取当前登录人拥有的菜单路由 - const dynamicRoutes = parseDynamicRoutes(processRoutes(data)); + const processRouteList = processRoutes(data); // 处理后的路由数据 + const dynamicRoutes = parseDynamicRoutes(processRouteList); routes.value = [...constantRoutes, ...dynamicRoutes]; @@ -117,8 +118,8 @@ const processRoutes = (routes: RouteVO[], isTopLevel: boolean = true): RouteVO[] return { ...args, component: isTopLevel || component !== "Layout" ? component : undefined, - // 递归处理children,标记为非顶层 - children: children && children.length > 0 ? processRoutes(children, false) : [], + // 递归处理children,标记为非顶层 todo 原样返回 children(undefined) + children: children && children.length > 0 ? processRoutes(children, false) : children, }; }); };