feat: 添加模式选择功能与页面更新
- 在 onboarding 页面中新增使用模式选择功能,用户可选择“戒烟打卡”或“记录抽烟”模式 - 更新个人资料页面以显示当前模式并允许用户切换模式 - 在 pages.json 中注册新的模式选择页面 - 优化首页和其他相关页面以适应新模式功能
This commit is contained in:
+11
-2
@@ -1,11 +1,12 @@
|
||||
import { defineStore } from 'pinia'
|
||||
import { storage, USER_KEY, SESSION_KEY } from '@/utils/storage'
|
||||
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)
|
||||
isLoggedIn: !!storage.get(SESSION_KEY),
|
||||
mode: storage.get(USER_MODE_KEY)
|
||||
}),
|
||||
|
||||
actions: {
|
||||
@@ -17,12 +18,20 @@ export const useUserStore = defineStore('user', {
|
||||
storage.set(SESSION_KEY, sessionKey)
|
||||
},
|
||||
|
||||
setMode(mode) {
|
||||
this.mode = mode
|
||||
storage.set(USER_MODE_KEY, mode)
|
||||
},
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user