From 93fe80dc685c47329bdb831e5c16236619d28425 Mon Sep 17 00:00:00 2001 From: RuoYi Date: Sat, 1 Mar 2025 15:04:28 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=89=8D=E7=AB=AF=E5=A4=84?= =?UTF-8?q?=E7=90=86=E8=B7=AF=E7=94=B1=E5=87=BD=E6=95=B0=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.js | 29 +++++++---------------------- 1 file changed, 7 insertions(+), 22 deletions(-) diff --git a/src/store/modules/permission.js b/src/store/modules/permission.js index 8a2b1a9..e1ef717 100644 --- a/src/store/modules/permission.js +++ b/src/store/modules/permission.js @@ -85,28 +85,13 @@ function filterAsyncRouter(asyncRouterMap, lastRouter = false, type = false) { function filterChildren(childrenMap, lastRouter = false) { var children = [] - childrenMap.forEach((el, index) => { - if (el.children && el.children.length) { - if (el.component === '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 === '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 } @@ -136,7 +121,7 @@ export const loadView = (view) => { res = () => modules[path](); } } - return res; + return res } export default usePermissionStore