|
@@ -33,19 +33,35 @@ export default {
|
|
|
|
|
|
...mapState("user", ['role']),
|
|
|
routes() {
|
|
|
- let role = this.role
|
|
|
- let regx = /\//g
|
|
|
- let roles = role.filter(res => res.match(regx).length === 1)
|
|
|
- let rolesChild = role.filter(res => res.match(regx).length !== 1)
|
|
|
- console.log(rolesChild,"rolesChildrolesChildrolesChildrolesChild");
|
|
|
- console.log(this.$router.options.routes,"rolesrolesrolesroles");
|
|
|
- let parent = [...this.$router.options.routes].filter(element => roles.includes(element.path));
|
|
|
- parent.forEach(element => {
|
|
|
- element.children = element.children.filter(res => rolesChild.includes(element.path+'/'+res.path))
|
|
|
- });
|
|
|
+ // let role = this.role
|
|
|
+ // let regx = /\//g
|
|
|
+ // let roles = role.filter(res => res.match(regx).length === 1)
|
|
|
+ // let rolesChild = role.filter(res => res.match(regx).length !== 1)
|
|
|
+ // console.log(rolesChild,"rolesChildrolesChildrolesChildrolesChild");
|
|
|
+ // console.log(this.$router.options.routes,"rolesrolesrolesroles");
|
|
|
+ // let parent = [...this.$router.options.routes].filter(element => roles.includes(element.path));
|
|
|
+ // parent.forEach(element => {
|
|
|
+ // element.children = element.children.filter(res => rolesChild.includes(element.path+'/'+res.path))
|
|
|
+ // });
|
|
|
|
|
|
- console.log(parent,"asdsadsa");
|
|
|
- return this.$router.options.routes
|
|
|
+ // console.log(parent,"asdsadsa");
|
|
|
+
|
|
|
+
|
|
|
+ let routes = this.$router.options.routes.copyWithin(0, 0)
|
|
|
+ let role = this.role
|
|
|
+ let regx = /\//g
|
|
|
+ let roles = role.filter(res => res.match(regx).length === 1)
|
|
|
+ let rolesChild = role.filter(res => res.match(regx).length !== 1)
|
|
|
+ let parent = routes.filter(element => roles.includes(element.path));
|
|
|
+ parent.forEach(element => {
|
|
|
+ element.children = element.children.filter(res => rolesChild.includes(element.path+'/'+res.path))
|
|
|
+ });
|
|
|
+
|
|
|
+ console.log(parent, this.$router.options.routes);
|
|
|
+ return parent
|
|
|
+
|
|
|
+
|
|
|
+ // return this.$router.options.routes
|
|
|
},
|
|
|
activeMenu() {
|
|
|
const route = this.$route
|