diff --git a/app.js b/app.js index 58cf59b..bb6c702 100644 --- a/app.js +++ b/app.js @@ -951,3 +951,89 @@ const hashId = location.hash.replace(/^#/, ""); : (SUTRAS.some((s) => s.id === prefs.sutra) ? prefs.sutra : SUTRAS[0]?.id); if (initSutraId) selectSutra(initSutraId); })(); + +// ===== 隐藏后台:2 秒内连点页脚提示 6 次打开管理面板(来源链接点击不计数) ===== +const footHint = document.getElementById("foot-hint"); +let hintClicks = 0; +let hintTimer = null; +footHint.addEventListener("click", (e) => { + if (e.target.closest("a")) return; + hintClicks += 1; + clearTimeout(hintTimer); + hintTimer = setTimeout(() => { hintClicks = 0; }, 2000); + if (hintClicks >= 6) { + hintClicks = 0; + openAdmin(); + } +}); + +/** 字节数转可读文本。 */ +function fmtBytes(n) { + if (n >= 1 << 20) return `${(n / (1 << 20)).toFixed(1)} MB`; + if (n >= 1 << 10) return `${(n / (1 << 10)).toFixed(1)} KB`; + return `${n} B`; +} + +/** 秒数转可读运行时长(如 2天3时 / 4时12分 / 35秒)。 */ +function fmtUptime(sec) { + const d = Math.floor(sec / 86400); + const h = Math.floor((sec % 86400) / 3600); + const m = Math.floor((sec % 3600) / 60); + if (d) return `${d}天${h}时`; + if (h) return `${h}时${m}分`; + if (m) return `${m}分${sec % 60}秒`; + return `${sec}秒`; +} + +/** 打开管理面板:本机偏好/播放状态 + 服务器 /api/stats 统计,可点"刷新"重拉。 */ +function openAdmin() { + const mask = document.createElement("div"); + mask.className = "admin-mask"; + const card = document.createElement("div"); + card.className = "admin-card"; + card.setAttribute("role", "dialog"); + card.setAttribute("aria-label", "管理面板"); + const voiceName = voiceSelect.options[voiceSelect.selectedIndex]?.textContent || "-"; + const bgmName = bgmSelect.options[bgmSelect.selectedIndex]?.textContent || "关"; + card.innerHTML = ` +