chore: track root project files and subrepos

This commit is contained in:
hajimi
2026-05-23 13:22:03 +08:00
parent 1624f023a2
commit 648ed678f3
1035 changed files with 154418 additions and 1 deletions
+43
View File
@@ -0,0 +1,43 @@
import { getUserCenter } from '@/api/user'
import { TOKEN_KEY } from '@/enums/cacheEnums'
import { defineStore } from 'pinia'
interface UserSate {
userInfo: Record<string, any>
token: string | null
temToken: string | null
}
export const useUserStore = defineStore({
id: 'userStore',
state: (): UserSate => {
const TOKEN = useCookie(TOKEN_KEY)
return {
userInfo: {},
token: TOKEN.value || null,
temToken: null
}
},
getters: {
isLogin: (state) => !!state.token
},
actions: {
async getUser() {
const data = await getUserCenter()
this.userInfo = data
},
setUser(userInfo: any) {
this.userInfo = userInfo
},
login(token: string) {
const TOKEN = useCookie(TOKEN_KEY)
this.token = token
TOKEN.value = token
},
logout() {
const TOKEN = useCookie(TOKEN_KEY)
this.token = null
this.userInfo = {}
TOKEN.value = null
}
}
})