上傳檔案到「modules/story-summary」
This commit is contained in:
@@ -1640,42 +1640,34 @@
|
||||
|
||||
bindEvents();
|
||||
|
||||
// === EASTER EGG: 连续点击标题「总结」5 次切换新野兽派主题(localStorage 持久化)===
|
||||
// === THEME SWITCHER ===
|
||||
(function () {
|
||||
const STORAGE_KEY = 'xb-theme-alt';
|
||||
const CSS_A = 'story-summary.css';
|
||||
const CSS_B = 'story-summary-a.css';
|
||||
const CSS_MAP = { default: 'story-summary.css', dark: 'story-summary.css', neo: 'story-summary-a.css', 'neo-dark': 'story-summary-a.css' };
|
||||
const link = document.querySelector('link[rel="stylesheet"]');
|
||||
if (!link) return;
|
||||
const sel = document.getElementById('theme-select');
|
||||
if (!link || !sel) return;
|
||||
|
||||
// 启动时:根据持久化状态设置 CSS
|
||||
if (localStorage.getItem(STORAGE_KEY) === '1') {
|
||||
link.setAttribute('href', CSS_B);
|
||||
function applyTheme(theme) {
|
||||
if (!CSS_MAP[theme]) return;
|
||||
link.setAttribute('href', CSS_MAP[theme]);
|
||||
document.documentElement.setAttribute('data-theme', (theme === 'dark' || theme === 'neo-dark') ? 'dark' : '');
|
||||
}
|
||||
|
||||
// 点击计数器
|
||||
let clickCount = 0, clickTimer = null;
|
||||
const trigger = document.querySelector('h1 span');
|
||||
if (!trigger) return;
|
||||
// 启动时恢复主题
|
||||
const saved = localStorage.getItem(STORAGE_KEY) || 'default';
|
||||
applyTheme(saved);
|
||||
sel.value = saved;
|
||||
|
||||
trigger.style.cursor = 'default';
|
||||
trigger.addEventListener('click', function () {
|
||||
clickCount++;
|
||||
clearTimeout(clickTimer);
|
||||
clickTimer = setTimeout(() => { clickCount = 0; }, 2000);
|
||||
|
||||
if (clickCount >= 5) {
|
||||
clickCount = 0;
|
||||
clearTimeout(clickTimer);
|
||||
const isAlt = localStorage.getItem(STORAGE_KEY) === '1';
|
||||
const next = isAlt ? CSS_A : CSS_B;
|
||||
localStorage.setItem(STORAGE_KEY, isAlt ? '0' : '1');
|
||||
link.setAttribute('href', next);
|
||||
console.log(`[Easter Egg] Theme toggled → ${next}`);
|
||||
}
|
||||
// 下拉框切换
|
||||
sel.addEventListener('change', function () {
|
||||
const theme = sel.value;
|
||||
applyTheme(theme);
|
||||
localStorage.setItem(STORAGE_KEY, theme);
|
||||
console.log(`[Theme] Switched → ${theme} (${CSS_MAP[theme]})`);
|
||||
});
|
||||
})();
|
||||
// === END EASTER EGG ===
|
||||
// === END THEME SWITCHER ===
|
||||
|
||||
// Notify parent
|
||||
postMsg('FRAME_READY');
|
||||
|
||||
Reference in New Issue
Block a user