好了
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,57 +1,57 @@
|
|||||||
<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
|
||||||
:default-active="activeMenu"
|
:default-active="activeMenu"
|
||||||
:collapse="isCollapse"
|
:collapse="isCollapse"
|
||||||
:background-color="settings.sideTheme === 'theme-dark' ? variables.menuBackground : variables.menuLightBackground"
|
:background-color="settings.sideTheme === 'theme-dark' ? variables.menuBackground : variables.menuLightBackground"
|
||||||
:text-color="settings.sideTheme === 'theme-dark' ? variables.menuColor : variables.menuLightColor"
|
:text-color="settings.sideTheme === 'theme-dark' ? variables.menuColor : variables.menuLightColor"
|
||||||
:unique-opened="true"
|
:unique-opened="true"
|
||||||
:active-text-color="settings.theme"
|
:active-text-color="settings.theme"
|
||||||
:collapse-transition="false"
|
:collapse-transition="false"
|
||||||
mode="vertical"
|
mode="vertical"
|
||||||
>
|
>
|
||||||
<sidebar-item
|
<sidebar-item
|
||||||
v-for="(route, index) in sidebarRouters"
|
v-for="(route, index) in sidebarRouters"
|
||||||
:key="route.path + index"
|
:key="route.path + index"
|
||||||
:item="route"
|
:item="route"
|
||||||
:base-path="route.path"
|
:base-path="route.path"
|
||||||
/>
|
/>
|
||||||
</el-menu>
|
</el-menu>
|
||||||
</el-scrollbar>
|
</el-scrollbar>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { mapGetters, mapState } from "vuex";
|
import { mapGetters, mapState } from "vuex";
|
||||||
import Logo from "./Logo";
|
import Logo from "./Logo";
|
||||||
import SidebarItem from "./SidebarItem";
|
import SidebarItem from "./SidebarItem";
|
||||||
import variables from "@/assets/styles/variables.scss";
|
import variables from "@/assets/styles/variables.scss";
|
||||||
|
|
||||||
export default {
|
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;
|
||||||
// if set path, the sidebar will highlight the path you set
|
// if set path, the sidebar will highlight the path you set
|
||||||
if (meta.activeMenu) {
|
if (meta.activeMenu) {
|
||||||
return meta.activeMenu;
|
return meta.activeMenu;
|
||||||
}
|
}
|
||||||
return path;
|
return path;
|
||||||
},
|
},
|
||||||
showLogo() {
|
showLogo() {
|
||||||
return this.$store.state.settings.sidebarLogo;
|
return this.$store.state.settings.sidebarLogo;
|
||||||
},
|
},
|
||||||
variables() {
|
variables() {
|
||||||
return variables;
|
return variables;
|
||||||
},
|
},
|
||||||
isCollapse() {
|
isCollapse() {
|
||||||
return !this.sidebar.opened;
|
return !this.sidebar.opened;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
@ -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