@@ -27,25 +27,34 @@ export const readedMessages = state => state.readedMessages
27
27
28
28
export const unreadMessages = state => state . unreadMessages
29
29
30
+ /**
31
+ * 在侧边栏展示时,如果当前路由 children 属性为空,则删除该路由
32
+ * @param {* } arr 路由配置项数据
33
+ */
30
34
function IterationDelateMenuChildren ( arr ) {
31
35
if ( arr . length ) {
32
36
for ( const i in arr ) {
33
37
if ( arr [ i ] . children && ! arr [ i ] . children . length ) {
34
- delete arr [ i ] // eslint-disable-line
35
- } else if ( arr [ i ] . children && ! arr [ i ] . children . length ) {
38
+ delete arr [ i ]
39
+ } else if ( arr [ i ] . children && arr [ i ] . children . length ) {
36
40
IterationDelateMenuChildren ( arr [ i ] . children )
37
41
}
38
42
}
39
43
}
40
44
return arr
41
45
}
42
46
47
+ /**
48
+ * Shaking 掉无限制路由
49
+ * @param {array } stageConfig 路由配置项数据
50
+ * @param {array } permissions 当前登录管理员所拥有的权限集合
51
+ * @param {object } currentUser 当前登录管理员
52
+ */
43
53
function permissionShaking ( stageConfig , permissions , currentUser ) {
44
- // eslint-disable-line
45
54
const shookConfig = stageConfig . filter ( route => {
46
55
if ( Util . hasPermission ( permissions , route , currentUser ) ) {
47
56
if ( route . children && route . children . length ) {
48
- route . children = permissionShaking ( route . children , permissions , currentUser ) // eslint-disable-line
57
+ route . children = permissionShaking ( route . children , permissions , currentUser )
49
58
}
50
59
return true
51
60
}
@@ -176,7 +185,7 @@ export const getStageInfo = state => {
176
185
return result
177
186
}
178
187
179
- if ( stages . children ) {
188
+ if ( stages . children && stages . children . length ) {
180
189
result = findStage ( stages . children , name )
181
190
if ( result ) {
182
191
result . unshift ( stages )
0 commit comments