好了
This commit is contained in:
@ -92,15 +92,13 @@ export default {
|
|||||||
const tmpPath = path.substring(1, path.length);
|
const tmpPath = path.substring(1, path.length);
|
||||||
activePath = "/" + tmpPath.substring(0, tmpPath.indexOf("/"));
|
activePath = "/" + tmpPath.substring(0, tmpPath.indexOf("/"));
|
||||||
} else if ("/index" == path || "" == path) {
|
} else if ("/index" == path || "" == path) {
|
||||||
if (!this.isFrist) {
|
this.isFrist = true;
|
||||||
this.isFrist = true;
|
|
||||||
} else {
|
|
||||||
activePath = "index";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
var routes = this.activeRoutes(activePath);
|
var routes = this.activeRoutes(activePath);
|
||||||
if (routes.length === 0) {
|
if (routes.length === 0) {
|
||||||
this.$store.commit("SET_SIDEBAR_ROUTERS", routes);
|
this.$store.commit("SET_SIDEBAR_MENU_HIDE", true);
|
||||||
|
}else {
|
||||||
|
this.$store.commit("SET_SIDEBAR_MENU_HIDE", false);
|
||||||
}
|
}
|
||||||
return activePath;
|
return activePath;
|
||||||
},
|
},
|
||||||
@ -159,9 +157,7 @@ export default {
|
|||||||
//TODO 第一个默认选中
|
//TODO 第一个默认选中
|
||||||
this.$store.commit("SET_SIDEBAR_ROUTERS", routes);
|
this.$store.commit("SET_SIDEBAR_ROUTERS", routes);
|
||||||
if(isTop){
|
if(isTop){
|
||||||
this.$store.commit("SET_SIDEBAR_ACTIVE_MENU", routes[0].path);
|
this.$router.push({path:routes[0].path});
|
||||||
let that = this;
|
|
||||||
that.$router.push({path:routes[0].path});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return routes;
|
return routes;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<template>
|
<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" />
|
<logo v-if="showLogo" :collapse="isCollapse" />
|
||||||
<el-scrollbar :class="settings.sideTheme" wrap-class="scrollbar-wrapper">
|
<el-scrollbar :class="settings.sideTheme" wrap-class="scrollbar-wrapper">
|
||||||
<el-menu
|
<el-menu
|
||||||
@ -33,7 +33,7 @@ export default {
|
|||||||
components: { SidebarItem, Logo },
|
components: { SidebarItem, Logo },
|
||||||
computed: {
|
computed: {
|
||||||
...mapState(["settings"]),
|
...mapState(["settings"]),
|
||||||
...mapGetters(["sidebarRouters", "sidebar"]),
|
...mapGetters(["sidebarRouters", "sidebar","sidebarMenuHide"]),
|
||||||
activeMenu() {
|
activeMenu() {
|
||||||
const route = this.$route;
|
const route = this.$route;
|
||||||
const { meta, path } = route;
|
const { meta, path } = route;
|
||||||
|
@ -132,7 +132,6 @@ export default {
|
|||||||
addTags() {
|
addTags() {
|
||||||
const { name } = this.$route
|
const { name } = this.$route
|
||||||
if (name) {
|
if (name) {
|
||||||
this.$store.commit("SET_SIDEBAR_ACTIVE_MENU", this.$route.path);
|
|
||||||
this.$store.dispatch('tagsView/addView', this.$route)
|
this.$store.dispatch('tagsView/addView', this.$route)
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
@ -191,7 +190,6 @@ export default {
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
toLastView(visitedViews, view) {
|
toLastView(visitedViews, view) {
|
||||||
console.log("打开了2")
|
|
||||||
const latestView = visitedViews.slice(-1)[0]
|
const latestView = visitedViews.slice(-1)[0]
|
||||||
if (latestView) {
|
if (latestView) {
|
||||||
this.$router.push(latestView.fullPath)
|
this.$router.push(latestView.fullPath)
|
||||||
@ -207,7 +205,6 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
openMenu(tag, e) {
|
openMenu(tag, e) {
|
||||||
console.log("打开了3",tag,e)
|
|
||||||
const menuMinWidth = 105
|
const menuMinWidth = 105
|
||||||
const offsetLeft = this.$el.getBoundingClientRect().left // container margin left
|
const offsetLeft = this.$el.getBoundingClientRect().left // container margin left
|
||||||
const offsetWidth = this.$el.offsetWidth // container width
|
const offsetWidth = this.$el.offsetWidth // container width
|
||||||
|
@ -14,6 +14,6 @@ const getters = {
|
|||||||
topbarRouters:state => state.permission.topbarRouters,
|
topbarRouters:state => state.permission.topbarRouters,
|
||||||
defaultRoutes:state => state.permission.defaultRoutes,
|
defaultRoutes:state => state.permission.defaultRoutes,
|
||||||
sidebarRouters:state => state.permission.sidebarRouters,
|
sidebarRouters:state => state.permission.sidebarRouters,
|
||||||
sidebarActiveMenu:state => state.permission.sidebarActiveMenu,
|
sidebarMenuHide:state => state.permission.sidebarMenuHide,
|
||||||
}
|
}
|
||||||
export default getters
|
export default getters
|
||||||
|
@ -12,7 +12,7 @@ const permission = {
|
|||||||
defaultRoutes: [],
|
defaultRoutes: [],
|
||||||
topbarRouters: [],
|
topbarRouters: [],
|
||||||
sidebarRouters: [],
|
sidebarRouters: [],
|
||||||
sidebarActiveMenu: null
|
sidebarMenuHide: false
|
||||||
},
|
},
|
||||||
mutations: {
|
mutations: {
|
||||||
SET_ROUTES: (state, routes) => {
|
SET_ROUTES: (state, routes) => {
|
||||||
@ -28,8 +28,8 @@ const permission = {
|
|||||||
SET_SIDEBAR_ROUTERS: (state, routes) => {
|
SET_SIDEBAR_ROUTERS: (state, routes) => {
|
||||||
state.sidebarRouters = routes
|
state.sidebarRouters = routes
|
||||||
}
|
}
|
||||||
,SET_SIDEBAR_ACTIVE_MENU: (state, sidebarActiveMenu) => {
|
,SET_SIDEBAR_MENU_HIDE: (state, sidebarMenuHide) => {
|
||||||
state.sidebarActiveMenu = sidebarActiveMenu
|
state.sidebarMenuHide = sidebarMenuHide
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
actions: {
|
actions: {
|
||||||
|
Reference in New Issue
Block a user