1
0
mirror of https://github.com/zclzone/vue-naive-admin.git synced 2026-01-23 08:00:22 +08:00

fix: 解决vite5循环引用导致热更新失效问题

This commit is contained in:
zclzone
2024-01-06 18:47:40 +08:00
parent c4fd0459ab
commit 2c9604a829
14 changed files with 351 additions and 317 deletions

View File

@@ -7,8 +7,6 @@
**********************************/
import { defineStore } from 'pinia'
import api from '@/api'
import { useAuthStore } from '@/store'
export const useUserStore = defineStore('user', {
state: () => ({
@@ -35,32 +33,8 @@ export const useUserStore = defineStore('user', {
},
},
actions: {
async getUserInfo() {
try {
const res = await api.getUser()
const { id, username, profile, roles, currentRole } = res.data || {}
this.userInfo = {
id,
username,
avatar: profile?.avatar,
nickName: profile?.nickName,
gender: profile?.gender,
address: profile?.address,
email: profile?.email,
roles,
currentRole,
}
return Promise.resolve(res.data)
} catch (error) {
return Promise.reject(error)
}
},
async switchCurrentRole(roleCode) {
const { data } = await api.switchCurrentRole(roleCode)
const authStore = useAuthStore()
authStore.resetLoginState()
await nextTick()
authStore.setToken(data)
setUser(user) {
this.userInfo = user
},
resetUser() {
this.$reset()