From f093da99ecb963d19d62dc0f242f00b20bc8895c Mon Sep 17 00:00:00 2001 From: 疯狂的狮子li <15040126243@163.com> Date: 星期三, 14 四月 2021 13:22:31 +0800 Subject: [PATCH] Merge branch 'master' of https://gitee.com/y_project/RuoYi-Vue into dev --- ruoyi-ui/src/components/TopNav/index.vue | 39 +++++++++++++++++++++++++-------------- 1 files changed, 25 insertions(+), 14 deletions(-) diff --git a/ruoyi-ui/src/components/TopNav/index.vue b/ruoyi-ui/src/components/TopNav/index.vue index fb15c59..3eebda4 100644 --- a/ruoyi-ui/src/components/TopNav/index.vue +++ b/ruoyi-ui/src/components/TopNav/index.vue @@ -30,6 +30,9 @@ <script> import { constantRoutes } from "@/router"; +// 涓嶉渶瑕佹縺娲荤殑璺敱 +const noactiveList = ["/user/profile", "/dict/type", "/gen/edit", "/job/log"]; + export default { data() { return { @@ -42,10 +45,13 @@ computed: { // 椤堕儴鏄剧ず鑿滃崟 topMenus() { - return this.routers.map((menu) => ({ - ...menu, - children: undefined, - })); + let topMenus = []; + this.routers.map((menu) => { + if (menu.hidden !== true) { + topMenus.push(menu); + } + }); + return topMenus; }, // 鎵�鏈夌殑璺敱淇℃伅 routers() { @@ -69,6 +75,12 @@ activeMenu() { const path = this.$route.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) { const tmpPath = path.substring(1, path.length); activePath = "/" + tmpPath.substring(0, tmpPath.indexOf("/")); @@ -83,21 +95,20 @@ return activePath; }, }, + beforeMount() { + window.addEventListener('resize', this.setVisibleNumber) + }, + beforeDestroy() { + window.removeEventListener('resize', this.setVisibleNumber) + }, mounted() { this.setVisibleNumber(); }, methods: { // 鏍规嵁瀹藉害璁$畻璁剧疆鏄剧ず鏍忔暟 setVisibleNumber() { - const width = document.body.getBoundingClientRect().width - 200; - const elWidth = this.$el.getBoundingClientRect().width; - const menuItemNodes = this.$el.children; - const menuWidth = Array.from(menuItemNodes).map( - (i) => i.getBoundingClientRect().width - ); - this.visibleNumber = ( - parseInt(width - elWidth) / parseInt(menuWidth) - ).toFixed(0); + const width = document.body.getBoundingClientRect().width / 3; + this.visibleNumber = parseInt(width / 85); }, // 鑿滃崟閫夋嫨浜嬩欢 handleSelect(key, keyPath) { @@ -119,7 +130,7 @@ }); } this.$store.commit("SET_SIDEBAR_ROUTERS", routes); - }, + } }, }; </script> -- Gitblit v1.9.3