Skip to content

Commit 3adb545

Browse files
committed
perf: 优化前端处理路由函数代码
1 parent 2c402eb commit 3adb545

File tree

1 file changed

+6
-21
lines changed

1 file changed

+6
-21
lines changed

ruoyi-fastapi-frontend/src/store/modules/permission.js

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -82,28 +82,13 @@ function filterAsyncRouter(asyncRouterMap, lastRouter = false, type = false) {
8282

8383
function filterChildren(childrenMap, lastRouter = false) {
8484
var children = []
85-
childrenMap.forEach((el, index) => {
86-
if (el.children && el.children.length) {
87-
if (el.component === 'ParentView' && !lastRouter) {
88-
el.children.forEach(c => {
89-
c.path = el.path + '/' + c.path
90-
if (c.children && c.children.length) {
91-
children = children.concat(filterChildren(c.children, c))
92-
return
93-
}
94-
children.push(c)
95-
})
96-
return
97-
}
98-
}
99-
if (lastRouter) {
100-
el.path = lastRouter.path + '/' + el.path
101-
if (el.children && el.children.length) {
102-
children = children.concat(filterChildren(el.children, el))
103-
return
104-
}
85+
childrenMap.forEach(el => {
86+
el.path = lastRouter ? lastRouter.path + '/' + el.path : el.path
87+
if (el.children && el.children.length && el.component === 'ParentView') {
88+
children = children.concat(filterChildren(el.children, el))
89+
} else {
90+
children.push(el)
10591
}
106-
children = children.concat(el)
10792
})
10893
return children
10994
}

0 commit comments

Comments
 (0)