Skip to content

Commit 50f5df4

Browse files
committed
bug fix
1 parent d83905b commit 50f5df4

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

src/App.vue

+10-10
Original file line numberDiff line numberDiff line change
@@ -67,16 +67,16 @@ export default {
6767
return resourceHash;
6868
},
6969
getRoutes: function(userPermissions) {
70-
let routeHash = {};
70+
let routePermission = {};
7171
let setMenu2Hash = function(array, base) {
72-
array.map(key => {
73-
if (key.route) {
74-
let hashKey = ((base ? base + '/' : '') + key.route).replace(/^\//, '');
75-
routeHash['/' + hashKey] = true;
76-
if (Array.isArray(key.children)) {
77-
setMenu2Hash(key.children, (base ? base + '/' : '') + key.route);
72+
array.forEach((router) => {
73+
if (router.route) {
74+
let hashKey = router.route.indexOf('/') === 0 ? router.route : [base, router.route].join(base === '/' ? '' : '/');
75+
routePermission[hashKey] = true;
76+
if (Array.isArray(router.children)) {
77+
setMenu2Hash(router.children, hashKey);
78+
}
7879
}
79-
}
8080
});
8181
};
8282
if (Array.isArray(userPermissions.menus)) {
@@ -93,7 +93,7 @@ export default {
9393
setMenu2Hash(arrayMenus);
9494
}
9595
// Get hash structure
96-
return routeHash;
96+
return routePermission;
9797
},
9898
extendRoutes: function(routePermission) {
9999
@@ -205,7 +205,7 @@ export default {
205205
*/
206206
207207
let routePermission = vm.getRoutes(userPermissions);
208-
208+
console.log('routePermission', routePermission)
209209
/*
210210
* Step 5
211211
* Setting request permission control through resourcePermission

0 commit comments

Comments
 (0)