Files
smt/src/utils/storage.js
T
hello-dd-code ec87a9fc55 feat(nsti): add nicotine personality test flow (#36)
* 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
2026-04-11 01:49:19 +08:00

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'