Pre Merge pull request !410 from 璐先生/master

This commit is contained in:
璐先生 2022-03-05 14:12:10 +00:00 committed by Gitee
commit 69218f84d7
7 changed files with 851 additions and 850 deletions

View File

@ -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;
},

View File

@ -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;

View File

@ -12,7 +12,7 @@ module.exports = {
/**
* 是否显示顶部导航
*/
topNav: false,
topNav: true,
/**
* 是否显示 tagsView

View File

@ -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

View File

@ -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: {