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

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

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