Commit f8bb7c07 by caoyanzhi

update: 菜单框架

parent 9945ba49
...@@ -37,6 +37,10 @@ export default { ...@@ -37,6 +37,10 @@ export default {
}; };
}, },
created() { created() {
this.$router.beforeEach((to, from, next) => {
this.activedMenu = this.getActivedMenu(this.getMenuByPath(to.path.slice(1)));
next();
});
this.getMenuList(); this.getMenuList();
}, },
methods: { methods: {
...@@ -51,6 +55,7 @@ export default { ...@@ -51,6 +55,7 @@ export default {
this.menuList = result; this.menuList = result;
this.flatMenuList = this.getFlatMenuList(result); this.flatMenuList = this.getFlatMenuList(result);
this.activedMenu = this.getActivedMenu(this.getMenuByPath(this.$route.path.slice(1))); this.activedMenu = this.getActivedMenu(this.getMenuByPath(this.$route.path.slice(1)));
this.setIndexRoute(result);
}); });
}, },
getFlatMenuList(menuList) { getFlatMenuList(menuList) {
...@@ -73,6 +78,26 @@ export default { ...@@ -73,6 +78,26 @@ export default {
}, },
getMenuByPath(path) { getMenuByPath(path) {
return this.flatMenuList.find(el => el.menuUrl == path) || {}; return this.flatMenuList.find(el => el.menuUrl == path) || {};
},
setIndexRoute(menuList) {
let path = '';
menuList.some(first => {
if (first.hasRight && first.isShow && Array.isArray(first.childList)) {
first.childList.some(second => {
if (second.hasRight && second.isShow && Array.isArray(second.childList)) {
second.childList.some(third => {
if (third.hasRight && third.isShow) {
path = third.menuUrl;
}
return third.hasRight && third.isShow;
});
}
return path;
});
}
return path;
});
this.$router.addRoutes([{ path: '/', redirect: '/' + path }]);
} }
} }
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment