|
@@ -7,12 +7,11 @@
|
|
|
<template v-for="(item, index) in topMenus">
|
|
|
<el-menu-item :style="{'--theme': theme}" :index="item.path" :key="index" v-if="index < visibleNumber">
|
|
|
<svg-icon
|
|
|
- v-if="item.meta && item.meta.icon && item.meta.icon !== '#'"
|
|
|
- :icon-class="item.meta.icon"/>
|
|
|
+ v-if="item.meta && item.meta.icon && item.meta.icon !== '#'"
|
|
|
+ :icon-class="item.meta.icon"/>
|
|
|
{{ item.meta.title }}
|
|
|
</el-menu-item>
|
|
|
</template>
|
|
|
-
|
|
|
<!-- 顶部菜单超出数量折叠 -->
|
|
|
<el-submenu :style="{'--theme': theme}" index="more" v-if="topMenus.length > visibleNumber">
|
|
|
<template slot="title">更多菜单</template>
|
|
@@ -32,7 +31,7 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-import { constantRoutes } from "@/router";
|
|
|
+import {constantRoutes} from "@/router";
|
|
|
|
|
|
// 隐藏侧边栏路由
|
|
|
const hideList = ['/index', '/user/profile'];
|
|
@@ -41,7 +40,7 @@ export default {
|
|
|
data() {
|
|
|
return {
|
|
|
// 顶部栏初始数
|
|
|
- visibleNumber: 5,
|
|
|
+ visibleNumber: 10,
|
|
|
// 当前激活菜单的 index
|
|
|
currentIndex: undefined
|
|
|
};
|
|
@@ -75,10 +74,10 @@ export default {
|
|
|
this.routers.map((router) => {
|
|
|
for (var item in router.children) {
|
|
|
if (router.children[item].parentPath === undefined) {
|
|
|
- if(router.path === "/") {
|
|
|
+ if (router.path === "/") {
|
|
|
router.children[item].path = "/" + router.children[item].path;
|
|
|
} else {
|
|
|
- if(!this.ishttp(router.children[item].path)) {
|
|
|
+ if (!this.ishttp(router.children[item].path)) {
|
|
|
router.children[item].path = router.path + "/" + router.children[item].path;
|
|
|
}
|
|
|
}
|
|
@@ -96,10 +95,9 @@ export default {
|
|
|
if (path !== undefined && path.lastIndexOf("/") > 0 && hideList.indexOf(path) === -1) {
|
|
|
const tmpPath = path.substring(1, path.length);
|
|
|
activePath = "/" + tmpPath.substring(0, tmpPath.indexOf("/"));
|
|
|
- if (!this.$route.meta.link) {
|
|
|
- this.$store.dispatch('app/toggleSideBarHide', false);
|
|
|
- }
|
|
|
- } else if(!this.$route.children) {
|
|
|
+ // 去除如果是链就不展示侧边栏的问题
|
|
|
+ this.$store.dispatch('app/toggleSideBarHide', false);
|
|
|
+ } else if (!this.$route.children) {
|
|
|
activePath = path;
|
|
|
this.$store.dispatch('app/toggleSideBarHide', true);
|
|
|
}
|
|
@@ -119,7 +117,7 @@ export default {
|
|
|
methods: {
|
|
|
// 根据宽度计算设置显示栏数
|
|
|
setVisibleNumber() {
|
|
|
- const width = document.body.getBoundingClientRect().width / 3;
|
|
|
+ const width = document.body.getBoundingClientRect().width / 1.8;
|
|
|
this.visibleNumber = parseInt(width / 85);
|
|
|
},
|
|
|
// 菜单选择事件
|
|
@@ -134,9 +132,9 @@ export default {
|
|
|
const routeMenu = this.childrenMenus.find(item => item.path === key);
|
|
|
if (routeMenu && routeMenu.query) {
|
|
|
let query = JSON.parse(routeMenu.query);
|
|
|
- this.$router.push({ path: key, query: query });
|
|
|
+ this.$router.push({path: key, query: query});
|
|
|
} else {
|
|
|
- this.$router.push({ path: key });
|
|
|
+ this.$router.push({path: key});
|
|
|
}
|
|
|
this.$store.dispatch('app/toggleSideBarHide', true);
|
|
|
} else {
|
|
@@ -155,7 +153,7 @@ export default {
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
- if(routes.length > 0) {
|
|
|
+ if (routes.length > 0) {
|
|
|
this.$store.commit("SET_SIDEBAR_ROUTERS", routes);
|
|
|
} else {
|
|
|
this.$store.dispatch('app/toggleSideBarHide', true);
|