Skip to content

Commit d97664f

Browse files
authored
fix:角色赋权与同步交互上的优化 (#45)
1 parent 32f83e4 commit d97664f

File tree

4 files changed

+15
-23
lines changed

4 files changed

+15
-23
lines changed

src/permission.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ router.beforeEach(async(to, from, next) => {
3434
try {
3535
// get user info
3636
// note: roles must be a object array! such as: ['admin'] or ,['developer','editor']
37-
const { id, roles } = await store.dispatch('user/getInfo')
38-
const userinfo = { id: id, roles: roles }
37+
const { ID, roles } = await store.dispatch('user/getInfo')
38+
const userinfo = { id: ID, roles: roles }
3939
// generate accessible routes map based on roles
4040

4141
const accessRoutes = await store.dispatch('permission/generateRoutes', userinfo)
@@ -49,7 +49,7 @@ router.beforeEach(async(to, from, next) => {
4949
next({ ...to, replace: true })
5050
} catch (error) {
5151
// remove token and go to login page to re-login
52-
52+
5353
await store.dispatch('user/resetToken')
5454
Message.error(error || 'Has Error')
5555
next(`/login?redirect=${to.path}`)
@@ -59,7 +59,7 @@ router.beforeEach(async(to, from, next) => {
5959
}
6060
} else {
6161
/* has no token*/
62-
62+
6363
if (whiteList.indexOf(to.path) !== -1) {
6464
//在免费登录白名单,直接去
6565
next()

src/store/modules/permission.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,9 @@ const actions = {
5959
generateRoutes({ commit }, userinfo) {
6060
return new Promise((resolve, reject) => {
6161
let accessedRoutes = []
62-
const {roles}=userinfo
62+
const {id, roles}=userinfo
6363
// 获取菜单树
64-
getUserMenuTreeByUserId({id: roles[0].ID}).then(res => {
64+
getUserMenuTreeByUserId({id: id}).then(res => {
6565

6666
const { data } = res
6767
const menuTree = data

src/views/personnel/group/index.vue

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,6 @@ export default {
468468
this.loading = false
469469
this.getTableData()
470470
})
471-
this.loading = false
472471
},
473472
syncWeComDepts() {
474473
this.loading = true
@@ -477,7 +476,6 @@ export default {
477476
this.loading = false
478477
this.getTableData()
479478
})
480-
this.loading = false
481479
},
482480
syncFeiShuDepts() {
483481
this.loading = true
@@ -486,7 +484,6 @@ export default {
486484
this.loading = false
487485
this.getTableData()
488486
})
489-
this.loading = false
490487
},
491488
syncOpenLdapDepts() {
492489
this.loading = true
@@ -495,8 +492,7 @@ export default {
495492
this.loading = false
496493
this.getTableData()
497494
})
498-
this.loading = false
499-
},
495+
}
500496
}
501497
}
502498
</script>

src/views/personnel/user/index.vue

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -720,38 +720,34 @@ export default {
720720
syncDingTalkUsers() {
721721
this.loading = true
722722
syncDingTalkUsersApi().then(res => {
723-
this.loading = false
724723
this.judgeResult(res)
724+
this.loading = false
725+
this.getTableData()
725726
})
726-
this.getTableData()
727-
this.loading = false
728727
},
729728
syncWeComUsers() {
730729
this.loading = true
731730
syncWeComUsersApi().then(res => {
732-
this.loading = false
733731
this.judgeResult(res)
732+
this.loading = false
733+
this.getTableData()
734734
})
735-
this.getTableData()
736-
this.loading = false
737735
},
738736
syncFeiShuUsers() {
739737
this.loading = true
740738
syncFeiShuUsersApi().then(res => {
741-
this.loading = false
742739
this.judgeResult(res)
740+
this.loading = false
741+
this.getTableData()
743742
})
744-
this.getTableData()
745-
this.loading = false
746743
},
747744
syncOpenLdapUsers() {
748745
this.loading = true
749746
syncOpenLdapUsersApi().then(res => {
750-
this.loading = false
751747
this.judgeResult(res)
748+
this.loading = false
749+
this.getTableData()
752750
})
753-
this.getTableData()
754-
this.loading = false
755751
}
756752
}
757753
}

0 commit comments

Comments
 (0)