提交 66d119be 编写于 作者: P piexlMax

路由嵌套情况下保证无边框功能可用

上级 e558faaa
......@@ -8,25 +8,16 @@ const notLayoutRouterArr = []
const keepAliveRoutersArr = []
const nameMap = {}
// 递归拼接parent Path 返回path
const formatParentPath = (parent) => {
let parentPath = ''
if (parent) {
parentPath = formatParentPath(parent.parent)
parentPath += parent.path
}
return parentPath
}
const formatRouter = (routes, routeMap, parent) => {
routes && routes.forEach(item => {
item.parent = parent
item.meta.btns = item.btns
item.meta.hidden = item.hidden
if (item.meta.defaultMenu === true) {
const parentPath = formatParentPath(parent)
item = { ...item, path: `${parentPath}/${item.path}` }
notLayoutRouterArr.push(item)
if (!parent) {
item = { ...item, path: `/${item.path}` }
notLayoutRouterArr.push(item)
}
}
routeMap[item.name] = item
if (item.children && item.children.length > 0) {
......@@ -93,7 +84,6 @@ export const useRouterStore = defineStore('router', () => {
formatRouter(asyncRouter, routeMap)
baseRouter[0].children = asyncRouter
if (notLayoutRouterArr.length !== 0) {
console.log(notLayoutRouterArr)
baseRouter.push(...notLayoutRouterArr)
}
asyncRouterHandle(baseRouter)
......
......@@ -9,8 +9,6 @@ export const asyncRouterHandle = (asyncRouter) => {
} else if (item.component.split('/')[0] === 'plugin') {
item.component = dynamicImport(pluginModules, item.component)
}
} else {
delete item['component']
}
if (item.children) {
asyncRouterHandle(item.children)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册