We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 703c0c5 commit ecf7558Copy full SHA for ecf7558
src/store/modules/user.js
@@ -132,6 +132,16 @@ const user = {
132
Cookies.remove('Admin-Token');
133
resolve();
134
});
135
+ },
136
+
137
+ // 动态修改权限
138
+ ChangeRole({ commit }, role) {
139
+ return new Promise(resolve => {
140
+ commit('SET_ROLES', [role]);
141
+ commit('SET_TOKEN', role);
142
+ Cookies.set('Admin-Token', role);
143
+ resolve();
144
+ })
145
}
146
147
};
src/views/permission/index.vue
@@ -23,8 +23,9 @@
23
},
24
watch: {
25
role(val) {
26
- this.$store.commit('SET_ROLES', [val]);
27
- this.$router.push({ path: '/permission/index?' + +new Date() });
+ this.$store.dispatch('ChangeRole', val).then(() => {
+ this.$router.push({ path: '/permission/index?' + +new Date() });
28
29
30
31
0 commit comments