|
|
@ -30,6 +30,9 @@ |
|
|
|
<script> |
|
|
|
<script> |
|
|
|
import { constantRoutes } from "@/router"; |
|
|
|
import { constantRoutes } from "@/router"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 不需要激活的路由 |
|
|
|
|
|
|
|
const noactiveList = ["/user/profile", "/dict/type", "/gen/edit", "/job/log"]; |
|
|
|
|
|
|
|
|
|
|
|
export default { |
|
|
|
export default { |
|
|
|
data() { |
|
|
|
data() { |
|
|
|
return { |
|
|
|
return { |
|
|
@ -42,10 +45,13 @@ export default { |
|
|
|
computed: { |
|
|
|
computed: { |
|
|
|
// 顶部显示菜单 |
|
|
|
// 顶部显示菜单 |
|
|
|
topMenus() { |
|
|
|
topMenus() { |
|
|
|
return this.routers.map((menu) => ({ |
|
|
|
let topMenus = []; |
|
|
|
...menu, |
|
|
|
this.routers.map((menu) => { |
|
|
|
children: undefined, |
|
|
|
if (menu.hidden === false) { |
|
|
|
})); |
|
|
|
topMenus.push(menu); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
return topMenus; |
|
|
|
}, |
|
|
|
}, |
|
|
|
// 所有的路由信息 |
|
|
|
// 所有的路由信息 |
|
|
|
routers() { |
|
|
|
routers() { |
|
|
@ -69,6 +75,12 @@ export default { |
|
|
|
activeMenu() { |
|
|
|
activeMenu() { |
|
|
|
const path = this.$route.path; |
|
|
|
const path = this.$route.path; |
|
|
|
let activePath = this.routers[0].path; |
|
|
|
let activePath = this.routers[0].path; |
|
|
|
|
|
|
|
var noactive = noactiveList.some(function (item) { |
|
|
|
|
|
|
|
return path.indexOf(item) !== -1; |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
if (noactive) { |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
if (path.lastIndexOf("/") > 0) { |
|
|
|
if (path.lastIndexOf("/") > 0) { |
|
|
|
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("/")); |
|
|
@ -89,7 +101,7 @@ export default { |
|
|
|
methods: { |
|
|
|
methods: { |
|
|
|
// 根据宽度计算设置显示栏数 |
|
|
|
// 根据宽度计算设置显示栏数 |
|
|
|
setVisibleNumber() { |
|
|
|
setVisibleNumber() { |
|
|
|
const width = document.body.getBoundingClientRect().width - 200; |
|
|
|
const width = document.body.getBoundingClientRect().width - 380; |
|
|
|
const elWidth = this.$el.getBoundingClientRect().width; |
|
|
|
const elWidth = this.$el.getBoundingClientRect().width; |
|
|
|
const menuItemNodes = this.$el.children; |
|
|
|
const menuItemNodes = this.$el.children; |
|
|
|
const menuWidth = Array.from(menuItemNodes).map( |
|
|
|
const menuWidth = Array.from(menuItemNodes).map( |
|
|
@ -119,7 +131,7 @@ export default { |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
this.$store.commit("SET_SIDEBAR_ROUTERS", routes); |
|
|
|
this.$store.commit("SET_SIDEBAR_ROUTERS", routes); |
|
|
|
}, |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
}; |
|
|
|
}; |
|
|
|
</script> |
|
|
|
</script> |
|
|
|