Files
smt/utils/storage.js
T
你çšnepiedg 31e504a997 feat: 添加模式选择功能与页面更新
- 在 onboarding 页面中新增使用模式选择功能,用户可选择“戒烟打卡”或“记录抽烟”模式
- 更新个人资料页面以显示当前模式并允许用户切换模式
- 在 pages.json 中注册新的模式选择页面
- 优化首页和其他相关页面以适应新模式功能
2026-03-18 00:06:01 +08:00

44 lines
909 B
JavaScript

const STORAGE_PREFIX = 'smt_'
export const storage = {
set(key, value) {
try {
uni.setStorageSync(STORAGE_PREFIX + key, JSON.stringify(value))
} catch (e) {
console.error('Storage set error:', e)
}
},
get(key, defaultValue = null) {
try {
const value = uni.getStorageSync(STORAGE_PREFIX + key)
return value ? JSON.parse(value) : defaultValue
} catch (e) {
console.error('Storage get error:', e)
return defaultValue
}
},
remove(key) {
try {
uni.removeStorageSync(STORAGE_PREFIX + key)
} catch (e) {
console.error('Storage remove error:', e)
}
},
clear() {
try {
uni.clearStorageSync()
} catch (e) {
console.error('Storage clear error:', e)
}
}
}
export const SESSION_KEY = 'session_key'
export const USER_KEY = 'user'
export const PROFILE_KEY = 'profile'
export const USER_MODE_KEY = 'user_mode'
export const QUIT_CHECKIN_KEY = 'quit_checkin'