Browse Source

优化前端处理路由函数代码

master
RuoYi 7 months ago
parent
commit
bd257f85e6
  1. 25
      ruoyi-ui/src/store/modules/permission.js

25
ruoyi-ui/src/store/modules/permission.js

@ -82,28 +82,13 @@ function filterAsyncRouter(asyncRouterMap, lastRouter = false, type = false) {
function filterChildren(childrenMap, lastRouter = false) { function filterChildren(childrenMap, lastRouter = false) {
var children = [] var children = []
childrenMap.forEach((el, index) => { childrenMap.forEach(el => {
if (el.children && el.children.length) { el.path = lastRouter ? lastRouter.path + '/' + el.path : el.path
if (el.component === 'ParentView' && !lastRouter) { if (el.children && el.children.length && el.component === 'ParentView') {
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
}
}
if (lastRouter) {
el.path = lastRouter.path + '/' + el.path
if (el.children && el.children.length) {
children = children.concat(filterChildren(el.children, el)) children = children.concat(filterChildren(el.children, el))
return } else {
} children.push(el)
} }
children = children.concat(el)
}) })
return children return children
} }

Loading…
Cancel
Save