Skip to content

Commit

Permalink
refactor: 更简单的 SET_USER_PERMISSIONS 遍历方式 (#485)
Browse files Browse the repository at this point in the history
  • Loading branch information
LeeSamFong authored Jul 24, 2021
1 parent 4c89ed7 commit 7948963
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions src/store/mutation.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,10 @@ export default {
},

[types.SET_USER_PERMISSIONS](state, permissions) {
const _permissions = []
for (let i = 0; i < permissions.length; i++) {
for (const key in permissions[i]) {
for (let j = 0; j < permissions[i][key].length; j++) {
_permissions.push(permissions[i][key][j].permission)
}
}
}
state.permissions = _permissions
state.permissions = permissions
.map(permission => Object.values(permission))
.flat(2)
.map(p => p.permission)
},

[types.SET_REFRESH_OPTION](state, option) {
Expand Down

0 comments on commit 7948963

Please sign in to comment.