fix: logout

This commit is contained in:
张传龙
2022-09-21 17:14:41 +08:00
parent 4a5b8dd005
commit 85a04fd06d
7 changed files with 91 additions and 56 deletions

View File

@@ -53,5 +53,8 @@ export const usePermissionStore = defineStore('permission', {
this.accessRoutes = accessRoutes
return accessRoutes
},
resetPermission() {
this.$reset()
},
},
})

View File

@@ -57,5 +57,9 @@ export const useTagsStore = defineStore('tag', {
router.push(filterTags[filterTags.length - 1].path)
}
},
resetTags() {
this.setTags([])
this.setActiveTag('')
},
},
})

View File

@@ -1,4 +1,6 @@
import { defineStore } from 'pinia'
import { resetRouter } from '@/router'
import { useTagsStore, usePermissionStore } from '@/store'
import { removeToken, toLogin } from '@/utils'
import api from '@/api'
@@ -34,8 +36,13 @@ export const useUserStore = defineStore('user', {
}
},
async logout() {
const { resetTags } = useTagsStore()
const { resetPermission } = usePermissionStore()
removeToken()
this.userInfo = {}
resetTags()
resetPermission()
resetRouter()
this.$reset()
toLogin()
},
setUserInfo(userInfo = {}) {