@@ -67,16 +67,16 @@ export default {
67
67
return resourceHash;
68
68
},
69
69
getRoutes : function (userPermissions ) {
70
- let routeHash = {};
70
+ let routePermission = {};
71
71
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
+ }
78
79
}
79
- }
80
80
});
81
81
};
82
82
if (Array .isArray (userPermissions .menus )) {
@@ -93,7 +93,7 @@ export default {
93
93
setMenu2Hash (arrayMenus);
94
94
}
95
95
// Get hash structure
96
- return routeHash ;
96
+ return routePermission ;
97
97
},
98
98
extendRoutes : function (routePermission ) {
99
99
@@ -205,7 +205,7 @@ export default {
205
205
*/
206
206
207
207
let routePermission = vm .getRoutes (userPermissions);
208
-
208
+ console . log ( ' routePermission ' , routePermission)
209
209
/*
210
210
* Step 5
211
211
* Setting request permission control through resourcePermission
0 commit comments