fix(portal): remember theme choice and restore light as default

Stop the one-time force-dark migration from overriding users, default first visits to light, and roll forced-dark browsers back to light once.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
John
2026-09-12 09:30:28 +08:00
parent 0e7e4829db
commit 06ba9e8bb7
3 changed files with 42 additions and 12 deletions
+9 -3
View File
@@ -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) {