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:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user