diff --git a/src/store/modules/user.js b/src/store/modules/user.js index 384a13232e235c104e86328a36199a016853cb21..a134f44f295728bb5c061da908f23ab05abf222a 100644 --- a/src/store/modules/user.js +++ b/src/store/modules/user.js @@ -132,6 +132,16 @@ const user = { Cookies.remove('Admin-Token'); resolve(); }); + }, + + // 动æ€ä¿®æ”¹æƒé™ + ChangeRole({ commit }, role) { + return new Promise(resolve => { + commit('SET_ROLES', [role]); + commit('SET_TOKEN', role); + Cookies.set('Admin-Token', role); + resolve(); + }) } } }; diff --git a/src/views/permission/index.vue b/src/views/permission/index.vue index b0b9540377eef1db1491f7fb0decc38e572efdc7..d11e8cd4ade345a8432fc4247b83da73e06a31e4 100644 --- a/src/views/permission/index.vue +++ b/src/views/permission/index.vue @@ -23,8 +23,9 @@ }, watch: { role(val) { - this.$store.commit('SET_ROLES', [val]); - this.$router.push({ path: '/permission/index?' + +new Date() }); + this.$store.dispatch('ChangeRole', val).then(() => { + this.$router.push({ path: '/permission/index?' + +new Date() }); + }) } } }