From f2adc5e5fa671b7543da23b08f3b2780a1d476fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=96=AF=E7=8B=82=E7=9A=84=E7=8B=AE=E5=AD=90Li?= <15040126243@163.com> Date: Mon, 3 Mar 2025 13:47:41 +0800 Subject: [PATCH] =?UTF-8?q?update=20=E4=BC=98=E5=8C=96=20=E5=89=8D?= =?UTF-8?q?=E7=AB=AF=E5=A4=84=E7=90=86=E8=B7=AF=E7=94=B1=E5=87=BD=E6=95=B0?= =?UTF-8?q?=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/store/modules/permission.ts | 33 +++++++++++---------------------- 1 file changed, 11 insertions(+), 22 deletions(-) diff --git a/src/store/modules/permission.ts b/src/store/modules/permission.ts index 43fcef8..a5da77b 100644 --- a/src/store/modules/permission.ts +++ b/src/store/modules/permission.ts @@ -23,6 +23,9 @@ export const usePermissionStore = defineStore('permission', () => { const getRoutes = (): RouteRecordRaw[] => { return routes.value as RouteRecordRaw[]; }; + const getDefaultRoutes = (): RouteRecordRaw[] => { + return defaultRoutes.value as RouteRecordRaw[]; + }; const getSidebarRoutes = (): RouteRecordRaw[] => { return sidebarRouters.value as RouteRecordRaw[]; }; @@ -97,29 +100,14 @@ export const usePermissionStore = defineStore('permission', () => { }; const filterChildren = (childrenMap: RouteRecordRaw[], lastRouter?: RouteRecordRaw): RouteRecordRaw[] => { let children: RouteRecordRaw[] = []; - childrenMap.forEach((el) => { - if (el.children && el.children.length) { - if (el.component?.toString() === 'ParentView' && !lastRouter) { - el.children.forEach((c) => { - c.path = el.path + '/' + c.path; - if (c.children && c.children.length) { - children = children.concat(filterChildren(c.children, c)); - return; - } - children.push(c); - }); - return; - } + childrenMap.forEach(el => { + el.path = lastRouter ? lastRouter.path + '/' + el.path : el.path; + if (el.children && el.children.length && el.component?.toString() === 'ParentView') { + children = children.concat(filterChildren(el.children, el)); + } else { + children.push(el); } - if (lastRouter) { - el.path = lastRouter.path + '/' + el.path; - if (el.children && el.children.length) { - children = children.concat(filterChildren(el.children, el)); - return; - } - } - children = children.concat(el); - }); + }) return children; }; return { @@ -129,6 +117,7 @@ export const usePermissionStore = defineStore('permission', () => { defaultRoutes, getRoutes, + getDefaultRoutes, getSidebarRoutes, getTopbarRoutes,