深色浅色主题切换;去掉新浪行情徽章;科技感卡片样式

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-06-15 13:04:48 +08:00
parent a35a08d2f6
commit db2443273f
8 changed files with 418 additions and 102 deletions
+36
View File
@@ -0,0 +1,36 @@
(function () {
var KEY = 'qihuo-theme';
function apply(theme) {
document.documentElement.setAttribute('data-theme', theme);
try {
localStorage.setItem(KEY, theme);
} catch (e) { /* ignore */ }
var btn = document.getElementById('theme-toggle');
if (btn) {
btn.setAttribute('data-active', theme);
btn.setAttribute('aria-label', theme === 'light' ? '切换到深色' : '切换到浅色');
}
}
var saved = null;
try {
saved = localStorage.getItem(KEY);
} catch (e) { /* ignore */ }
if (saved === 'light' || saved === 'dark') {
apply(saved);
} else {
var prefersLight = window.matchMedia && window.matchMedia('(prefers-color-scheme: light)').matches;
apply(prefersLight ? 'light' : 'dark');
}
document.addEventListener('DOMContentLoaded', function () {
var btn = document.getElementById('theme-toggle');
if (!btn) return;
btn.addEventListener('click', function () {
var cur = document.documentElement.getAttribute('data-theme') || 'dark';
apply(cur === 'dark' ? 'light' : 'dark');
});
});
})();