|
@@ -87,7 +87,7 @@ export default { |
|
@@ -87,7 +87,7 @@ export default { |
|
87
|
// 默认激活的菜单
|
87
|
// 默认激活的菜单
|
|
88
|
activeMenu() {
|
88
|
activeMenu() {
|
|
89
|
const path = this.$route.path;
|
89
|
const path = this.$route.path;
|
|
90
|
- let activePath = this.routers[0].path;
|
90
|
+ let activePath = this.defaultRouter();
|
|
91
|
if (path.lastIndexOf("/") > 0) {
|
91
|
if (path.lastIndexOf("/") > 0) {
|
|
92
|
const tmpPath = path.substring(1, path.length);
|
92
|
const tmpPath = path.substring(1, path.length);
|
|
93
|
activePath = "/" + tmpPath.substring(0, tmpPath.indexOf("/"));
|
93
|
activePath = "/" + tmpPath.substring(0, tmpPath.indexOf("/"));
|
|
@@ -100,7 +100,7 @@ export default { |
|
@@ -100,7 +100,7 @@ export default { |
|
100
|
}
|
100
|
}
|
|
101
|
var routes = this.activeRoutes(activePath);
|
101
|
var routes = this.activeRoutes(activePath);
|
|
102
|
if (routes.length === 0) {
|
102
|
if (routes.length === 0) {
|
|
103
|
- activePath = this.currentIndex || this.routers[0].path
|
103
|
+ activePath = this.currentIndex || this.defaultRouter()
|
|
104
|
this.activeRoutes(activePath);
|
104
|
this.activeRoutes(activePath);
|
|
105
|
}
|
105
|
}
|
|
106
|
return activePath;
|
106
|
return activePath;
|
|
@@ -121,6 +121,17 @@ export default { |
|
@@ -121,6 +121,17 @@ export default { |
|
121
|
const width = document.body.getBoundingClientRect().width / 3;
|
121
|
const width = document.body.getBoundingClientRect().width / 3;
|
|
122
|
this.visibleNumber = parseInt(width / 85);
|
122
|
this.visibleNumber = parseInt(width / 85);
|
|
123
|
},
|
123
|
},
|
|
|
|
124
|
+ // 默认激活的路由
|
|
|
|
125
|
+ defaultRouter() {
|
|
|
|
126
|
+ let router;
|
|
|
|
127
|
+ Object.keys(this.routers).some((key) => {
|
|
|
|
128
|
+ if (!this.routers[key].hidden) {
|
|
|
|
129
|
+ router = this.routers[key].path;
|
|
|
|
130
|
+ return true;
|
|
|
|
131
|
+ }
|
|
|
|
132
|
+ });
|
|
|
|
133
|
+ return router;
|
|
|
|
134
|
+ },
|
|
124
|
// 菜单选择事件
|
135
|
// 菜单选择事件
|
|
125
|
handleSelect(key, keyPath) {
|
136
|
handleSelect(key, keyPath) {
|
|
126
|
this.currentIndex = key;
|
137
|
this.currentIndex = key;
|