首页加夜晚模式:右上角月亮/太阳切换,样式由 tools/gen-night.py 自动翻色 (v26100460)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
22
js/app.js
22
js/app.js
@@ -3,7 +3,7 @@
|
||||
(function () {
|
||||
'use strict';
|
||||
/* 页面版本号(YYMMDD+序号):显示在「关于兜爸心选」页底部;bump 时同步 head 注释与 ?v= */
|
||||
var VER = '26100459';
|
||||
var VER = '26100460';
|
||||
const $ = (s, c) => (c || document).querySelector(s);
|
||||
const $$ = (s, c) => Array.from((c || document).querySelectorAll(s));
|
||||
|
||||
@@ -559,6 +559,26 @@
|
||||
}
|
||||
$$('[data-sheet="open"]').forEach(b => b.addEventListener('click', openSheet));
|
||||
/* 「今日脚印」右上角掀角里的祈福树 → 宝宝祈福树(2026-10-05)。stopPropagation:卡片本身点了会跳档案。走业务域名反代 /qifu-shu/,jumpApp 负责带身份和上报。 */
|
||||
/* 夜晚模式开关(2026-10-05):<html class="night"> + localStorage 'mmbox.night.v1',样式全在 night.css。
|
||||
首屏的 class 由 index.html <head> 的内联脚本先加好,这里只管点击切换和按钮状态。 */
|
||||
const NIGHT_KEY = 'mmbox.night.v1';
|
||||
const nb = $('#nightBtn');
|
||||
const syncNightBtn = () => {
|
||||
const on = document.documentElement.classList.contains('night');
|
||||
if (nb) { nb.setAttribute('aria-pressed', on ? 'true' : 'false'); nb.setAttribute('aria-label', on ? '切换到白天模式' : '切换到夜晚模式'); }
|
||||
const tc = document.querySelector('meta[name=theme-color]'); if (tc) tc.content = on ? '#2A2340' : '#F4593C';
|
||||
};
|
||||
syncNightBtn();
|
||||
if (nb) nb.addEventListener('click', e => {
|
||||
e.stopPropagation();
|
||||
const root = document.documentElement;
|
||||
root.classList.add('nt-anim');
|
||||
const on = root.classList.toggle('night');
|
||||
try { localStorage.setItem(NIGHT_KEY, on ? '1' : '0'); } catch (err) {}
|
||||
syncNightBtn();
|
||||
setTimeout(() => root.classList.remove('nt-anim'), 450);
|
||||
});
|
||||
|
||||
const QIFU_URL = location.origin + '/qifu-shu/';
|
||||
const fq = $('#fpQifu');
|
||||
if (fq) fq.addEventListener('click', e => { e.preventDefault(); e.stopPropagation(); jumpApp(QIFU_URL); });
|
||||
|
||||
Reference in New Issue
Block a user