提交 ecf7558e 编写于 作者: P Pan

refine permission example

上级 703c0c5c
...@@ -132,6 +132,16 @@ const user = { ...@@ -132,6 +132,16 @@ const user = {
Cookies.remove('Admin-Token'); Cookies.remove('Admin-Token');
resolve(); resolve();
}); });
},
// 动态修改权限
ChangeRole({ commit }, role) {
return new Promise(resolve => {
commit('SET_ROLES', [role]);
commit('SET_TOKEN', role);
Cookies.set('Admin-Token', role);
resolve();
})
} }
} }
}; };
......
...@@ -23,8 +23,9 @@ ...@@ -23,8 +23,9 @@
}, },
watch: { watch: {
role(val) { role(val) {
this.$store.commit('SET_ROLES', [val]); this.$store.dispatch('ChangeRole', val).then(() => {
this.$router.push({ path: '/permission/index?' + +new Date() }); this.$router.push({ path: '/permission/index?' + +new Date() });
})
} }
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册