ec87a9fc55
* fix: polish logs filter and stats money display * fix: align floating tabs on logs and stats * feat: enhance user profile and achievement features - Add functionality for users to update their profile picture and nickname - Implement achievement theme selection in onboarding - Update API integration for profile updates and achievement themes - Refine UI elements for better user interaction and experience * feat: 梦想清单页与戒烟相关 API - 梦想清单:系统导航栏、浮动添加、图标来自后台预设 - dream-presets API、pages.json 导航样式 Made-with: Cursor * feat(nsti): add nicotine personality test flow
43 lines
985 B
JavaScript
43 lines
985 B
JavaScript
import { defineStore } from 'pinia'
|
|
import { storage, USER_KEY, SESSION_KEY, USER_MODE_KEY, QUIT_CHECKIN_KEY } from '@/utils/storage'
|
|
|
|
export const useUserStore = defineStore('user', {
|
|
state: () => ({
|
|
user: storage.get(USER_KEY),
|
|
sessionKey: storage.get(SESSION_KEY),
|
|
isLoggedIn: !!storage.get(SESSION_KEY),
|
|
mode: storage.get(USER_MODE_KEY)
|
|
}),
|
|
|
|
actions: {
|
|
setUser(user, sessionKey) {
|
|
this.user = user
|
|
this.sessionKey = sessionKey
|
|
this.isLoggedIn = true
|
|
storage.set(USER_KEY, user)
|
|
storage.set(SESSION_KEY, sessionKey)
|
|
},
|
|
|
|
setMode(mode) {
|
|
this.mode = mode
|
|
storage.set(USER_MODE_KEY, mode)
|
|
},
|
|
|
|
updateUser(fields) {
|
|
this.user = { ...this.user, ...fields }
|
|
storage.set(USER_KEY, this.user)
|
|
},
|
|
|
|
logout() {
|
|
this.user = null
|
|
this.sessionKey = null
|
|
this.isLoggedIn = false
|
|
this.mode = null
|
|
storage.remove(USER_KEY)
|
|
storage.remove(SESSION_KEY)
|
|
storage.remove(USER_MODE_KEY)
|
|
storage.remove(QUIT_CHECKIN_KEY)
|
|
}
|
|
}
|
|
})
|