|
|
@ -19,7 +19,7 @@ const permission = { |
|
|
|
routes: [], |
|
|
|
addRoutes: [], |
|
|
|
originRoutes: [], |
|
|
|
selectTab: sessionStorage.getItem("topTab") || "dike", |
|
|
|
selectTab: sessionStorage.getItem("topTab") || "", |
|
|
|
namesJumpMenu: [], // 跳转菜单
|
|
|
|
}, |
|
|
|
mutations: { |
|
|
@ -164,6 +164,7 @@ const permission = { |
|
|
|
|
|
|
|
// 切换tab
|
|
|
|
changeTopTab({ commit, dispatch }, payload) { |
|
|
|
console.log("payload >>>>> ", payload); |
|
|
|
commit("SET_SELECT_TAB", payload); |
|
|
|
dispatch("changeRoutes"); |
|
|
|
}, |
|
|
@ -199,30 +200,37 @@ function filterAsyncRouter(asyncRouterMap) { |
|
|
|
function resolveChildrenRoutes(routes, pickRoute = permission.state.selectTab) { |
|
|
|
if (!routes?.length) return; |
|
|
|
let pickRoutePath = `/${pickRoute}`; |
|
|
|
let tempRoutesArr = []; |
|
|
|
let tempRoutesNameArr = []; |
|
|
|
let newChildrenRoutes = []; |
|
|
|
if (!pickRoutes.includes(pickRoutePath)) { |
|
|
|
// TODO
|
|
|
|
} |
|
|
|
let pathPickRoutesArr = []; |
|
|
|
let namePickRoutesArr = []; |
|
|
|
// 去掉掉不需要的菜单
|
|
|
|
let newRoutes = routes.filter((v) => { |
|
|
|
// 提取需要拾取的路由菜单
|
|
|
|
if (pickRoutes.includes(v.path)) { |
|
|
|
tempRoutesArr.push(v); |
|
|
|
pathPickRoutesArr.push(v); |
|
|
|
} |
|
|
|
// 只要是名称叫“一张图”的都不展示在菜单上
|
|
|
|
if (v.meta?.title && pickRouteNames.includes(v.meta.title)) { |
|
|
|
if (!v.hidden) |
|
|
|
tempRoutesNameArr.push({ |
|
|
|
if (!v.hidden) { |
|
|
|
namePickRoutesArr.push({ |
|
|
|
...v, |
|
|
|
label: v.meta.title, |
|
|
|
value: v.path, |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
return !pickRoutes.includes(v.path) && v.meta?.title !== "一张图"; |
|
|
|
}); |
|
|
|
if (tempRoutesArr.length) { |
|
|
|
let parentRoute = tempRoutesArr.filter( |
|
|
|
// 提取三大模块菜单的子路由
|
|
|
|
let pickChildrenRoutes = []; |
|
|
|
if (pathPickRoutesArr.length) { |
|
|
|
let parentRoute = pathPickRoutesArr.filter( |
|
|
|
(v) => v.path === pickRoutePath |
|
|
|
)?.[0]; |
|
|
|
if (parentRoute) { |
|
|
|
newChildrenRoutes = |
|
|
|
pickChildrenRoutes = |
|
|
|
parentRoute.children |
|
|
|
?.map((v) => { |
|
|
|
return { |
|
|
@ -252,18 +260,18 @@ function resolveChildrenRoutes(routes, pickRoute = permission.state.selectTab) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// tempRoutesNameArr 赋值给 namesJumpMenu
|
|
|
|
permission.state.namesJumpMenu = tempRoutesNameArr; |
|
|
|
// namePickRoutesArr 赋值给 namesJumpMenu
|
|
|
|
permission.state.namesJumpMenu = namePickRoutesArr; |
|
|
|
|
|
|
|
return { |
|
|
|
topTabList: tempRoutesArr.map((v) => { |
|
|
|
topTabList: pathPickRoutesArr.map((v) => { |
|
|
|
return { |
|
|
|
orderNum: v.orderNum, |
|
|
|
label: v.meta.title, |
|
|
|
value: v.path.slice(1), |
|
|
|
}; |
|
|
|
}), |
|
|
|
newRoutes: [...newChildrenRoutes, ...newRoutes], |
|
|
|
newRoutes: [...pickChildrenRoutes, ...newRoutes], |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|