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
+11 -6
View File
@@ -1,20 +1,26 @@
<!doctype html>
<html lang="zh-CN" data-theme="dark">
<html lang="zh-CN" data-theme="light">
<head>
<meta charset="UTF-8" />
<meta name="theme-color" content="#f4f1ea" />
<script>
(function () {
var storageKey = 'memind-theme';
var migrationKey = 'memind-theme-migration';
var migrationVersion = 'dark-default-2026-09-11';
var migrationVersion = 'light-default-2026-09-12';
if (localStorage.getItem(migrationKey) !== migrationVersion) {
localStorage.setItem(storageKey, 'dark');
var previousMigration = localStorage.getItem(migrationKey);
var stored = localStorage.getItem(storageKey);
if (previousMigration === 'dark-default-2026-09-11' && stored !== 'light') {
localStorage.setItem(storageKey, 'light');
}
localStorage.setItem(migrationKey, migrationVersion);
}
var stored = localStorage.getItem(storageKey);
var theme = stored === 'light' || stored === 'dark' ? stored : 'dark';
var theme = localStorage.getItem(storageKey) === 'dark' ? 'dark' : 'light';
document.documentElement.dataset.theme = theme;
document.documentElement.style.colorScheme = theme;
var meta = document.querySelector('meta[name="theme-color"]');
if (meta) meta.setAttribute('content', theme === 'dark' ? '#0f1419' : '#f4f1ea');
})();
</script>
<meta
@@ -23,7 +29,6 @@
/>
<meta name="mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="theme-color" content="#0f1419" />
<title>TKMind</title>
</head>
<body>