Browse Source

顶部菜单排除隐藏的默认路由

tags/v3.1.0
RuoYi 3 years ago
parent
commit
e798f46876
  1. 15
      ruoyi-ui/src/components/TopNav/index.vue
  2. 2
      ruoyi-ui/src/router/index.js

15
ruoyi-ui/src/components/TopNav/index.vue

@ -87,7 +87,7 @@ export default { @@ -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 { @@ -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 { @@ -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;

2
ruoyi-ui/src/router/index.js

@ -5,8 +5,6 @@ Vue.use(Router) @@ -5,8 +5,6 @@ Vue.use(Router)
/* Layout */
import Layout from '@/layout'
import ParentView from '@/components/ParentView';
import InnerLink from '@/layout/components/InnerLink'
/**
* Note: 路由配置项

Loading…
Cancel
Save