Pre Merge pull request !410 from 璐先生/master
This commit is contained in:
commit
69218f84d7
@ -92,16 +92,13 @@ export default {
|
||||
const tmpPath = path.substring(1, path.length);
|
||||
activePath = "/" + tmpPath.substring(0, tmpPath.indexOf("/"));
|
||||
} else if ("/index" == path || "" == path) {
|
||||
if (!this.isFrist) {
|
||||
this.isFrist = true;
|
||||
} else {
|
||||
activePath = "index";
|
||||
}
|
||||
this.isFrist = true;
|
||||
}
|
||||
var routes = this.activeRoutes(activePath);
|
||||
if (routes.length === 0) {
|
||||
activePath = this.currentIndex || this.defaultRouter()
|
||||
this.activeRoutes(activePath);
|
||||
this.$store.commit("SET_SIDEBAR_MENU_HIDE", true);
|
||||
}else {
|
||||
this.$store.commit("SET_SIDEBAR_MENU_HIDE", false);
|
||||
}
|
||||
return activePath;
|
||||
},
|
||||
@ -142,22 +139,26 @@ export default {
|
||||
// /redirect 路径内部打开
|
||||
this.$router.push({ path: key.replace("/redirect", "") });
|
||||
} else {
|
||||
// 显示左侧联动菜单
|
||||
this.activeRoutes(key);
|
||||
// 显示左侧联动菜单顶部菜单
|
||||
this.activeRoutes(key,true);
|
||||
}
|
||||
},
|
||||
// 当前激活的路由
|
||||
activeRoutes(key) {
|
||||
activeRoutes(key,isTop) {
|
||||
var routes = [];
|
||||
if (this.childrenMenus && this.childrenMenus.length > 0) {
|
||||
this.childrenMenus.map((item) => {
|
||||
if (key == item.parentPath || (key == "index" && "" == item.path)) {
|
||||
if (key == item.parentPath) {
|
||||
routes.push(item);
|
||||
}
|
||||
});
|
||||
}
|
||||
if(routes.length > 0) {
|
||||
//TODO 第一个默认选中
|
||||
this.$store.commit("SET_SIDEBAR_ROUTERS", routes);
|
||||
if(isTop){
|
||||
this.$router.push({path:routes[0].path});
|
||||
}
|
||||
}
|
||||
return routes;
|
||||
},
|
||||
|
@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<div :class="{'has-logo':showLogo}" :style="{ backgroundColor: settings.sideTheme === 'theme-dark' ? variables.menuBackground : variables.menuLightBackground }">
|
||||
<div v-show="!sidebarMenuHide" :class="{'has-logo':showLogo}" :style="{ backgroundColor: settings.sideTheme === 'theme-dark' ? variables.menuBackground : variables.menuLightBackground }">
|
||||
<logo v-if="showLogo" :collapse="isCollapse" />
|
||||
<el-scrollbar :class="settings.sideTheme" wrap-class="scrollbar-wrapper">
|
||||
<el-menu
|
||||
@ -33,7 +33,7 @@ export default {
|
||||
components: { SidebarItem, Logo },
|
||||
computed: {
|
||||
...mapState(["settings"]),
|
||||
...mapGetters(["sidebarRouters", "sidebar"]),
|
||||
...mapGetters(["sidebarRouters", "sidebar","sidebarMenuHide"]),
|
||||
activeMenu() {
|
||||
const route = this.$route;
|
||||
const { meta, path } = route;
|
||||
|
@ -12,7 +12,7 @@ module.exports = {
|
||||
/**
|
||||
* 是否显示顶部导航
|
||||
*/
|
||||
topNav: false,
|
||||
topNav: true,
|
||||
|
||||
/**
|
||||
* 是否显示 tagsView
|
||||
|
@ -14,5 +14,6 @@ const getters = {
|
||||
topbarRouters:state => state.permission.topbarRouters,
|
||||
defaultRoutes:state => state.permission.defaultRoutes,
|
||||
sidebarRouters:state => state.permission.sidebarRouters,
|
||||
sidebarMenuHide:state => state.permission.sidebarMenuHide,
|
||||
}
|
||||
export default getters
|
||||
|
@ -11,7 +11,8 @@ const permission = {
|
||||
addRoutes: [],
|
||||
defaultRoutes: [],
|
||||
topbarRouters: [],
|
||||
sidebarRouters: []
|
||||
sidebarRouters: [],
|
||||
sidebarMenuHide: false
|
||||
},
|
||||
mutations: {
|
||||
SET_ROUTES: (state, routes) => {
|
||||
@ -22,15 +23,13 @@ const permission = {
|
||||
state.defaultRoutes = constantRoutes.concat(routes)
|
||||
},
|
||||
SET_TOPBAR_ROUTES: (state, routes) => {
|
||||
// 顶部导航菜单默认添加统计报表栏指向首页
|
||||
const index = [{
|
||||
path: 'index',
|
||||
meta: { title: '统计报表', icon: 'dashboard' }
|
||||
}]
|
||||
state.topbarRouters = routes.concat(index);
|
||||
state.topbarRouters = routes;
|
||||
},
|
||||
SET_SIDEBAR_ROUTERS: (state, routes) => {
|
||||
state.sidebarRouters = routes
|
||||
}
|
||||
,SET_SIDEBAR_MENU_HIDE: (state, sidebarMenuHide) => {
|
||||
state.sidebarMenuHide = sidebarMenuHide
|
||||
},
|
||||
},
|
||||
actions: {
|
||||
|
Loading…
x
Reference in New Issue
Block a user