2
0
mirror of https://github.com/acepanel/panel.git synced 2026-02-04 11:27:17 +08:00
Files
panel/web/src/store/modules/user/index.ts
2024-10-28 23:44:48 +08:00

37 lines
744 B
Go

import { resetRouter } from '@/router'
import { usePermissionStore, useTabStore } from '@/store'
import { toLogin } from '@/utils'
export interface UserInfo {
id?: string
username?: string
role?: Array<string>
}
export const useUserStore = defineStore('user', {
state: (): UserInfo => {
return {
id: '',
username: '',
role: []
}
},
actions: {
set(info: UserInfo) {
this.id = info.id
this.username = info.username
this.role = info.role
},
logout() {
const { resetTabs } = useTabStore()
const { resetPermission } = usePermissionStore()
resetPermission()
resetTabs()
resetRouter()
this.$reset()
toLogin()
}
},
persist: true
})