移除重复路由

This commit is contained in:
LILU
2022-01-12 11:51:03 +08:00
parent a3b59a2b9f
commit 1edc4868ad
2 changed files with 3 additions and 9 deletions

View File

@ -100,8 +100,7 @@ export default {
} }
var routes = this.activeRoutes(activePath); var routes = this.activeRoutes(activePath);
if (routes.length === 0) { if (routes.length === 0) {
activePath = this.currentIndex || this.defaultRouter() this.$store.commit("SET_SIDEBAR_ROUTERS", routes);
this.activeRoutes(activePath);
} }
return activePath; return activePath;
}, },
@ -151,7 +150,7 @@ export default {
var routes = []; var routes = [];
if (this.childrenMenus && this.childrenMenus.length > 0) { if (this.childrenMenus && this.childrenMenus.length > 0) {
this.childrenMenus.map((item) => { this.childrenMenus.map((item) => {
if (key == item.parentPath || (key == "index" && "" == item.path)) { if (key == item.parentPath) {
routes.push(item); routes.push(item);
} }
}); });

View File

@ -23,12 +23,7 @@ const permission = {
state.defaultRoutes = constantRoutes.concat(routes) state.defaultRoutes = constantRoutes.concat(routes)
}, },
SET_TOPBAR_ROUTES: (state, routes) => { SET_TOPBAR_ROUTES: (state, routes) => {
// 顶部导航菜单默认添加统计报表栏指向首页 state.topbarRouters = routes;
const index = [{
path: 'index',
meta: { title: '统计报表', icon: 'dashboard' }
}]
state.topbarRouters = routes.concat(index);
}, },
SET_SIDEBAR_ROUTERS: (state, routes) => { SET_SIDEBAR_ROUTERS: (state, routes) => {
state.sidebarRouters = routes state.sidebarRouters = routes