mirror of
https://github.com/LifeArchiveProject/WeChatDataAnalysis.git
synced 2026-06-18 15:54:08 +08:00
94ec5c9a1c
- 新增主题 store 与本地持久化能力,支持侧边栏切换浅色/深色模式 - 将聊天页、会话列表、标题栏、弹窗等配色改为 CSS 变量统一管理 - 适配定位卡片、引用气泡、系统提示等聊天消息组件在不同主题下的可读性 - 同步整理首页、解密页、联系人页、朋友圈页等页面背景与交互样式
47 lines
910 B
JavaScript
47 lines
910 B
JavaScript
import { defineStore } from 'pinia'
|
|
|
|
import {
|
|
UI_THEME_DARK,
|
|
UI_THEME_LIGHT,
|
|
applyUiTheme,
|
|
normalizeUiTheme,
|
|
readUiTheme,
|
|
writeUiTheme,
|
|
} from '~/lib/ui-theme'
|
|
|
|
export const useThemeStore = defineStore('theme', () => {
|
|
const theme = ref(UI_THEME_LIGHT)
|
|
const initialized = ref(false)
|
|
|
|
const isDark = computed(() => theme.value === UI_THEME_DARK)
|
|
|
|
const set = (nextTheme) => {
|
|
theme.value = normalizeUiTheme(nextTheme, UI_THEME_LIGHT)
|
|
writeUiTheme(theme.value)
|
|
applyUiTheme(theme.value)
|
|
}
|
|
|
|
const init = () => {
|
|
if (initialized.value) {
|
|
applyUiTheme(theme.value)
|
|
return
|
|
}
|
|
initialized.value = true
|
|
theme.value = readUiTheme(UI_THEME_LIGHT)
|
|
applyUiTheme(theme.value)
|
|
}
|
|
|
|
const toggle = () => {
|
|
set(isDark.value ? UI_THEME_LIGHT : UI_THEME_DARK)
|
|
}
|
|
|
|
return {
|
|
theme,
|
|
initialized,
|
|
isDark,
|
|
init,
|
|
set,
|
|
toggle,
|
|
}
|
|
})
|