feat: support primary color customization

This commit is contained in:
codytseng 2025-10-18 23:18:44 +08:00
parent b17846f264
commit 28dad7373f
21 changed files with 644 additions and 43 deletions

View file

@ -4,7 +4,8 @@ import {
MEDIA_AUTO_LOAD_POLICY,
NOTIFICATION_LIST_STYLE,
SUPPORTED_KINDS,
StorageKey
StorageKey,
TPrimaryColor
} from '@/constants'
import { isSameAccount } from '@/lib/account'
import { randomString } from '@/lib/random'
@ -49,6 +50,7 @@ class LocalStorageService {
private mediaAutoLoadPolicy: TMediaAutoLoadPolicy = MEDIA_AUTO_LOAD_POLICY.ALWAYS
private shownCreateWalletGuideToastPubkeys: Set<string> = new Set()
private sidebarCollapse: boolean = false
private primaryColor: TPrimaryColor = 'DEFAULT'
constructor() {
if (!LocalStorageService.instance) {
@ -196,6 +198,9 @@ class LocalStorageService {
this.sidebarCollapse = window.localStorage.getItem(StorageKey.SIDEBAR_COLLAPSE) === 'true'
this.primaryColor =
(window.localStorage.getItem(StorageKey.PRIMARY_COLOR) as TPrimaryColor) ?? 'DEFAULT'
// Clean up deprecated data
window.localStorage.removeItem(StorageKey.ACCOUNT_PROFILE_EVENT_MAP)
window.localStorage.removeItem(StorageKey.ACCOUNT_FOLLOW_LIST_EVENT_MAP)
@ -488,6 +493,15 @@ class LocalStorageService {
this.sidebarCollapse = collapse
window.localStorage.setItem(StorageKey.SIDEBAR_COLLAPSE, collapse.toString())
}
getPrimaryColor() {
return this.primaryColor
}
setPrimaryColor(color: TPrimaryColor) {
this.primaryColor = color
window.localStorage.setItem(StorageKey.PRIMARY_COLOR, color)
}
}
const instance = new LocalStorageService()