diff --git a/web/src/pinia/modules/router.js b/web/src/pinia/modules/router.js index d32e303837b0899b20ca4bfde28e48e49ce3af3f..36b9ec009bb8934a25cdd35740ec709c6d58223f 100644 --- a/web/src/pinia/modules/router.js +++ b/web/src/pinia/modules/router.js @@ -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) diff --git a/web/src/utils/asyncRouter.js b/web/src/utils/asyncRouter.js index e79b78c2048d0d65adf9afbf032b5674ca135b65..dfa62bbd1ca54fc2c3773c7856e65bf8a4e1d7bc 100644 --- a/web/src/utils/asyncRouter.js +++ b/web/src/utils/asyncRouter.js @@ -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)