From c43f9bc3c2433982706d289833aa2d5cb856ea16 Mon Sep 17 00:00:00 2001 From: RuoYi Date: Sat, 24 Jul 2021 18:20:55 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A1=B6=E9=83=A8=E8=8F=9C=E5=8D=95=E6=8E=92?= =?UTF-8?q?=E9=99=A4=E9=9A=90=E8=97=8F=E7=9A=84=E9=BB=98=E8=AE=A4=E8=B7=AF?= =?UTF-8?q?=E7=94=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ruoyi-ui/src/components/TopNav/index.vue | 15 +++++++++++++-- ruoyi-ui/src/router/index.js | 2 -- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/ruoyi-ui/src/components/TopNav/index.vue b/ruoyi-ui/src/components/TopNav/index.vue index c8837f2..edb9c53 100644 --- a/ruoyi-ui/src/components/TopNav/index.vue +++ b/ruoyi-ui/src/components/TopNav/index.vue @@ -87,7 +87,7 @@ export default { // 默认激活的菜单 activeMenu() { const path = this.$route.path; - let activePath = this.routers[0].path; + let activePath = this.defaultRouter(); if (path.lastIndexOf("/") > 0) { const tmpPath = path.substring(1, path.length); activePath = "/" + tmpPath.substring(0, tmpPath.indexOf("/")); @@ -100,7 +100,7 @@ export default { } var routes = this.activeRoutes(activePath); if (routes.length === 0) { - activePath = this.currentIndex || this.routers[0].path + activePath = this.currentIndex || this.defaultRouter() this.activeRoutes(activePath); } return activePath; @@ -121,6 +121,17 @@ export default { const width = document.body.getBoundingClientRect().width / 3; this.visibleNumber = parseInt(width / 85); }, + // 默认激活的路由 + defaultRouter() { + let router; + Object.keys(this.routers).some((key) => { + if (!this.routers[key].hidden) { + router = this.routers[key].path; + return true; + } + }); + return router; + }, // 菜单选择事件 handleSelect(key, keyPath) { this.currentIndex = key; diff --git a/ruoyi-ui/src/router/index.js b/ruoyi-ui/src/router/index.js index 7f0b105..d0c4b0b 100644 --- a/ruoyi-ui/src/router/index.js +++ b/ruoyi-ui/src/router/index.js @@ -5,8 +5,6 @@ Vue.use(Router) /* Layout */ import Layout from '@/layout' -import ParentView from '@/components/ParentView'; -import InnerLink from '@/layout/components/InnerLink' /** * Note: 路由配置项