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
47 lines
1.0 KiB
JavaScript
47 lines
1.0 KiB
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'
|
|
export const NSTI_RESULT_KEY = 'nsti_latest_result'
|
|
export const NSTI_HISTORY_KEY = 'nsti_history'
|
|
export const NSTI_DRAFT_KEY = 'nsti_draft'
|