mirror of
https://github.com/yangzongzhuan/RuoYi-Vue3.git
synced 2025-09-27 14:52:40 +00:00
优化前端处理路由函数代码
This commit is contained in:
@@ -85,28 +85,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 => {
|
children = children.concat(filterChildren(el.children, el))
|
||||||
c.path = el.path + '/' + c.path
|
} else {
|
||||||
if (c.children && c.children.length) {
|
children.push(el)
|
||||||
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))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
children = children.concat(el)
|
|
||||||
})
|
})
|
||||||
return children
|
return children
|
||||||
}
|
}
|
||||||
@@ -136,7 +121,7 @@ export const loadView = (view) => {
|
|||||||
res = () => modules[path]();
|
res = () => modules[path]();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return res;
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
export default usePermissionStore
|
export default usePermissionStore
|
||||||
|
Reference in New Issue
Block a user