fix: 修正退出后 userStore.userInfo 存在残留的问题 (#357)

This commit is contained in:
PDieE 2022-11-17 10:09:25 +08:00 committed by GitHub
parent e171e280e4
commit 5759c680ac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -9,7 +9,7 @@ const InitUserInfo = {
export const useUserStore = defineStore('user', {
state: () => ({
token: localStorage.getItem(TOKEN_NAME) || 'main_token', // 默认token不走权限
userInfo: InitUserInfo,
userInfo: { ...InitUserInfo },
}),
getters: {
roles: (state) => {
@ -73,7 +73,7 @@ export const useUserStore = defineStore('user', {
async logout() {
localStorage.removeItem(TOKEN_NAME);
this.token = '';
this.userInfo = InitUserInfo;
this.userInfo = { ...InitUserInfo };
},
async removeToken() {
this.token = '';