diff --git a/index.html b/index.html index cdecdcf..3b9e4a3 100644 --- a/index.html +++ b/index.html @@ -1,20 +1,26 @@ - + + - TKMind diff --git a/public/oa-drive/app.js b/public/oa-drive/app.js index 9376b7a..c1020fc 100644 --- a/public/oa-drive/app.js +++ b/public/oa-drive/app.js @@ -3,18 +3,24 @@ const THEME_STORAGE_KEY = 'memind-theme'; const THEME_MIGRATION_KEY = 'memind-theme-migration'; - const THEME_MIGRATION_VERSION = 'dark-default-2026-09-11'; + const THEME_MIGRATION_VERSION = 'light-default-2026-09-12'; + const FORCE_DARK_MIGRATION_VERSION = 'dark-default-2026-09-11'; + const DEFAULT_THEME = 'light'; function migrateThemePreferenceIfNeeded() { if (localStorage.getItem(THEME_MIGRATION_KEY) === THEME_MIGRATION_VERSION) return; - localStorage.setItem(THEME_STORAGE_KEY, 'dark'); + const previousMigration = localStorage.getItem(THEME_MIGRATION_KEY); + const stored = localStorage.getItem(THEME_STORAGE_KEY); + if (previousMigration === FORCE_DARK_MIGRATION_VERSION && stored !== 'light') { + localStorage.setItem(THEME_STORAGE_KEY, 'light'); + } localStorage.setItem(THEME_MIGRATION_KEY, THEME_MIGRATION_VERSION); } function getStoredTheme() { const stored = localStorage.getItem(THEME_STORAGE_KEY); if (stored === 'dark' || stored === 'light') return stored; - return 'dark'; + return DEFAULT_THEME; } function applyTheme(theme) { diff --git a/src/utils/theme.ts b/src/utils/theme.ts index 9f8a267..f6c58ac 100644 --- a/src/utils/theme.ts +++ b/src/utils/theme.ts @@ -2,19 +2,37 @@ export type MemindTheme = 'light' | 'dark'; export const THEME_STORAGE_KEY = 'memind-theme'; export const THEME_MIGRATION_KEY = 'memind-theme-migration'; -export const THEME_MIGRATION_VERSION = 'dark-default-2026-09-11'; +export const THEME_MIGRATION_VERSION = 'light-default-2026-09-12'; +export const DEFAULT_THEME: MemindTheme = 'light'; + +const FORCE_DARK_MIGRATION_VERSION = 'dark-default-2026-09-11'; + +const THEME_COLOR = { + light: '#f4f1ea', + dark: '#0f1419', +} as const; + +function syncThemeColor(theme: MemindTheme) { + const meta = document.querySelector('meta[name="theme-color"]'); + if (meta) meta.setAttribute('content', THEME_COLOR[theme]); +} export function migrateThemePreferenceIfNeeded() { if (typeof localStorage === 'undefined') return; if (localStorage.getItem(THEME_MIGRATION_KEY) === THEME_MIGRATION_VERSION) return; - localStorage.setItem(THEME_STORAGE_KEY, 'dark'); + const previousMigration = localStorage.getItem(THEME_MIGRATION_KEY); + const stored = localStorage.getItem(THEME_STORAGE_KEY); + if (previousMigration === FORCE_DARK_MIGRATION_VERSION && stored !== 'light') { + localStorage.setItem(THEME_STORAGE_KEY, 'light'); + } localStorage.setItem(THEME_MIGRATION_KEY, THEME_MIGRATION_VERSION); } export function getStoredTheme(): MemindTheme { + if (typeof localStorage === 'undefined') return DEFAULT_THEME; const stored = localStorage.getItem(THEME_STORAGE_KEY); if (stored === 'dark' || stored === 'light') return stored; - return 'dark'; + return DEFAULT_THEME; } export function applyTheme(theme: MemindTheme) { @@ -22,6 +40,7 @@ export function applyTheme(theme: MemindTheme) { document.documentElement.dataset.theme = normalized; document.documentElement.style.colorScheme = normalized; localStorage.setItem(THEME_STORAGE_KEY, normalized); + syncThemeColor(normalized); window.dispatchEvent(new CustomEvent('memind-theme-change', { detail: { theme: normalized } })); }