mirror of
https://github.com/linux-odyssey/linux-odyssey.git
synced 2026-11-06 03:20:13 +08:00
36 lines
685 B
TypeScript
36 lines
685 B
TypeScript
import { defineStore } from 'pinia'
|
|
import { getUserProfile } from '../utils/api'
|
|
|
|
interface IProgress {
|
|
quest: string
|
|
sessions: string[]
|
|
completed: boolean
|
|
startedAt: Date
|
|
finishedAt?: Date
|
|
}
|
|
|
|
export interface UserProfile {
|
|
username: string
|
|
email: string
|
|
progress: Map<string, IProgress>
|
|
}
|
|
|
|
const useUserProfile = defineStore('userProfile', {
|
|
state: (): UserProfile => ({
|
|
username: '',
|
|
email: '',
|
|
progress: new Map<string, IProgress>(),
|
|
}),
|
|
actions: {
|
|
async loadUserProfile() {
|
|
const res = await getUserProfile()
|
|
this.$patch(res)
|
|
},
|
|
async resetUserProfile() {
|
|
this.$reset()
|
|
},
|
|
},
|
|
})
|
|
|
|
export default useUserProfile
|