mirror of
https://github.com/LifeArchiveProject/WeChatDataAnalysis.git
synced 2026-02-19 06:10:52 +08:00
feat(settings): 新增独立设置页并统一桌面偏好读取
新增 /settings 页面,集中管理桌面行为与启动偏好开关 抽离 desktop-settings 工具,统一本地布尔配置读写 首页默认跳转逻辑改为复用设置工具,减少重复实现
This commit is contained in:
20
frontend/utils/desktop-settings.js
Normal file
20
frontend/utils/desktop-settings.js
Normal file
@@ -0,0 +1,20 @@
|
||||
export const DESKTOP_SETTING_AUTO_REALTIME_KEY = 'desktop.settings.autoRealtime'
|
||||
export const DESKTOP_SETTING_DEFAULT_TO_CHAT_KEY = 'desktop.settings.defaultToChatWhenData'
|
||||
|
||||
export const readLocalBoolSetting = (key, fallback = false) => {
|
||||
if (!process.client) return !!fallback
|
||||
try {
|
||||
const raw = localStorage.getItem(String(key || ''))
|
||||
if (raw == null) return !!fallback
|
||||
return String(raw).toLowerCase() === 'true'
|
||||
} catch {
|
||||
return !!fallback
|
||||
}
|
||||
}
|
||||
|
||||
export const writeLocalBoolSetting = (key, value) => {
|
||||
if (!process.client) return
|
||||
try {
|
||||
localStorage.setItem(String(key || ''), value ? 'true' : 'false')
|
||||
} catch {}
|
||||
}
|
||||
Reference in New Issue
Block a user