|
@@ -66,7 +66,7 @@ export default {
|
|
|
return this.activeTopMenu;
|
|
|
}
|
|
|
const route = this.$route;
|
|
|
- /*
|
|
|
+ /*
|
|
|
const { meta, path } = route;
|
|
|
if (meta.belongTopMenu) {
|
|
|
return meta.belongTopMenu;
|
|
@@ -79,7 +79,36 @@ export default {
|
|
|
return this.resolvePathUrl(this.routes.path);
|
|
|
}
|
|
|
},
|
|
|
+ mounted() {
|
|
|
+ this.onlyOneChild = null;
|
|
|
+ },
|
|
|
methods: {
|
|
|
+ hasOneShowingChild(children = [], parent) {
|
|
|
+ const showingChildren = children.filter((item) => {
|
|
|
+ if (item.hidden) {
|
|
|
+ return false;
|
|
|
+ } else {
|
|
|
+ // Temp set(will be used if only has one showing child)
|
|
|
+ this.onlyOneChild = item;
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ // When there is only one child router, the child router is displayed by default
|
|
|
+
|
|
|
+ if (showingChildren.length === 1) {
|
|
|
+ // console.log(showingChildren[0].meta.title)
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ // Show parent if there are no child router to display
|
|
|
+ if (showingChildren.length === 0) {
|
|
|
+ this.onlyOneChild = { ...parent, path: "", noShowingChildren: true };
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ return false;
|
|
|
+ },
|
|
|
menuIsShow(route) {
|
|
|
let activeTopMenu = this.getBasePath;
|
|
|
const { meta } = route;
|
|
@@ -96,15 +125,26 @@ export default {
|
|
|
return true;
|
|
|
}
|
|
|
});
|
|
|
+ // console.log(showChildren)
|
|
|
if (showChildren.length > 0) {
|
|
|
return true;
|
|
|
}
|
|
|
return false;
|
|
|
},
|
|
|
+ // resolvePath(routePath) {
|
|
|
+ // if (isExternal(routePath)) {
|
|
|
+ // return routePath;
|
|
|
+ // }
|
|
|
+ // if (isExternal(this.basePath)) {
|
|
|
+ // return this.basePath;
|
|
|
+ // }
|
|
|
+ // return path.resolve(this.basePath, routePath);
|
|
|
+ // },
|
|
|
resolvePathUrl(routePath) {
|
|
|
if (isExternal(routePath)) {
|
|
|
return routePath;
|
|
|
}
|
|
|
+ // console.log(this.resolvePath, routePath)
|
|
|
return path.resolve(this.resolvePath, routePath);
|
|
|
}
|
|
|
}
|