feat(portal): one-time migration forces dark theme for all users
Reset saved light preferences once via memind-theme-migration marker so existing visitors switch to dark on next load; inline boot script and OA drive share the same migration version. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+8
-2
@@ -4,8 +4,14 @@
|
||||
<meta charset="UTF-8" />
|
||||
<script>
|
||||
(function () {
|
||||
var key = 'memind-theme';
|
||||
var stored = localStorage.getItem(key);
|
||||
var storageKey = 'memind-theme';
|
||||
var migrationKey = 'memind-theme-migration';
|
||||
var migrationVersion = 'dark-default-2026-09-11';
|
||||
if (localStorage.getItem(migrationKey) !== migrationVersion) {
|
||||
localStorage.setItem(storageKey, 'dark');
|
||||
localStorage.setItem(migrationKey, migrationVersion);
|
||||
}
|
||||
var stored = localStorage.getItem(storageKey);
|
||||
var theme = stored === 'light' || stored === 'dark' ? stored : 'dark';
|
||||
document.documentElement.dataset.theme = theme;
|
||||
document.documentElement.style.colorScheme = theme;
|
||||
|
||||
@@ -2,6 +2,14 @@
|
||||
'use strict';
|
||||
|
||||
const THEME_STORAGE_KEY = 'memind-theme';
|
||||
const THEME_MIGRATION_KEY = 'memind-theme-migration';
|
||||
const THEME_MIGRATION_VERSION = 'dark-default-2026-09-11';
|
||||
|
||||
function migrateThemePreferenceIfNeeded() {
|
||||
if (localStorage.getItem(THEME_MIGRATION_KEY) === THEME_MIGRATION_VERSION) return;
|
||||
localStorage.setItem(THEME_STORAGE_KEY, 'dark');
|
||||
localStorage.setItem(THEME_MIGRATION_KEY, THEME_MIGRATION_VERSION);
|
||||
}
|
||||
|
||||
function getStoredTheme() {
|
||||
const stored = localStorage.getItem(THEME_STORAGE_KEY);
|
||||
@@ -32,6 +40,7 @@
|
||||
}
|
||||
|
||||
function initTheme() {
|
||||
migrateThemePreferenceIfNeeded();
|
||||
applyTheme(getStoredTheme());
|
||||
updateThemeToggleLabel();
|
||||
window.addEventListener('storage', (event) => {
|
||||
|
||||
@@ -1,6 +1,15 @@
|
||||
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 function migrateThemePreferenceIfNeeded() {
|
||||
if (typeof localStorage === 'undefined') return;
|
||||
if (localStorage.getItem(THEME_MIGRATION_KEY) === THEME_MIGRATION_VERSION) return;
|
||||
localStorage.setItem(THEME_STORAGE_KEY, 'dark');
|
||||
localStorage.setItem(THEME_MIGRATION_KEY, THEME_MIGRATION_VERSION);
|
||||
}
|
||||
|
||||
export function getStoredTheme(): MemindTheme {
|
||||
const stored = localStorage.getItem(THEME_STORAGE_KEY);
|
||||
@@ -17,6 +26,7 @@ export function applyTheme(theme: MemindTheme) {
|
||||
}
|
||||
|
||||
export function initTheme() {
|
||||
migrateThemePreferenceIfNeeded();
|
||||
applyTheme(getStoredTheme());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user