Skip to content

Commit 7948963

Browse files
authored
refactor: 更简单的 SET_USER_PERMISSIONS 遍历方式 (#485)
1 parent 4c89ed7 commit 7948963

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

src/store/mutation.js

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,10 @@ export default {
3131
},
3232

3333
[types.SET_USER_PERMISSIONS](state, permissions) {
34-
const _permissions = []
35-
for (let i = 0; i < permissions.length; i++) {
36-
for (const key in permissions[i]) {
37-
for (let j = 0; j < permissions[i][key].length; j++) {
38-
_permissions.push(permissions[i][key][j].permission)
39-
}
40-
}
41-
}
42-
state.permissions = _permissions
34+
state.permissions = permissions
35+
.map(permission => Object.values(permission))
36+
.flat(2)
37+
.map(p => p.permission)
4338
},
4439

4540
[types.SET_REFRESH_OPTION](state, option) {

0 commit comments

Comments
 (0)