diff --git a/webui/app.js b/webui/app.js index dc7dc37..5634299 100644 --- a/webui/app.js +++ b/webui/app.js @@ -541,6 +541,84 @@ function initShotFullscreen() { }); } +function initShortcutsHelp() { + const isMac = /Mac|iPhone|iPad|iPod/i.test(navigator.platform || navigator.userAgent || ""); + const mod = isMac ? "⌘" : "Ctrl"; + let overlay = null; + const ITEMS = [ + { keys: [mod, "K"], desc: "聚焦配置搜索" }, + { keys: [mod, "S"], desc: "保存配置" }, + { keys: [mod, "Enter"], desc: "开始运行" }, + { keys: ["Esc"], desc: "清空搜索 / 关闭弹层" }, + { keys: ["?"], desc: "显示此帮助" }, + ]; + const open = () => { + if (overlay) return; + overlay = document.createElement("div"); + overlay.className = "shortcutsOverlay"; + overlay.innerHTML = ` + + `; + document.body.appendChild(overlay); + requestAnimationFrame(() => overlay.classList.add("isVisible")); + overlay.addEventListener("click", (e) => { + if (e.target === overlay || e.target.closest(".shortcutsClose")) close(); + }); + }; + const close = () => { + if (!overlay) return; + overlay.classList.remove("isVisible"); + const ref = overlay; + setTimeout(() => { try { ref.remove(); } catch (_) {} }, 160); + overlay = null; + }; + document.addEventListener("keydown", (e) => { + // 输入框聚焦时不拦截 ? 字符 + const inField = /^(INPUT|TEXTAREA|SELECT)$/i.test(document.activeElement?.tagName || ""); + if (e.key === "?" && !inField && !e.metaKey && !e.ctrlKey) { + e.preventDefault(); + overlay ? close() : open(); + return; + } + if (e.key === "Escape" && overlay) { + e.preventDefault(); + close(); + } + }); +} + +function startReservationsCountdownTick() { + // 每秒 tick 更新预约卡倒计时与高亮类,无需等待 stats 轮询 + setInterval(() => { + const items = document.querySelectorAll(".reservationItem[data-future-ts]"); + if (!items.length) return; + const now = Date.now() / 1000; + items.forEach((card) => { + const fut = Number(card.dataset.futureTs) || 0; + if (!fut) return; + const remain = Math.max(0, Math.floor(fut - now)); + const remainEl = card.querySelector(".reservationRemain"); + if (remainEl) { + remainEl.textContent = remain > 0 + ? `${Math.floor(remain / 60)}分${remain % 60}秒后` + : "已到开奖时间"; + } + card.classList.toggle("isImminent", remain > 0 && remain <= 60); + card.classList.toggle("isDue", remain === 0); + }); + }, 1000); +} + function initTabs() { const tabButtons = Array.from(document.querySelectorAll(".tabBtn[data-target]")); const panels = Array.from(document.querySelectorAll(".panel[data-panel]")); @@ -1748,6 +1826,8 @@ async function pollReservations() { // 60s 内开奖:高亮提醒 if (remain > 0 && remain <= 60) card.classList.add("isImminent"); else if (remain === 0) card.classList.add("isDue"); + // 把 future_ts 存到卡片,供倒计时 tick 实时刷新 + if (future_ts) card.dataset.futureTs = String(future_ts); card.innerHTML = `
@@ -1757,7 +1837,7 @@ async function pollReservations() {
内容:${escapeHtml(item.content || '-')}
开奖时间:${item.future_str || '-'}
-
剩余时间:${remainStr}
+
剩余时间:${remainStr}
发现位置:${item.pos_seen || 0}
直播间(清洗后):${escapeHtml(item.room_title || '-')}
直播间原文:${escapeHtml(item.room_title_raw || '-')}
@@ -1898,6 +1978,11 @@ async function pollStats() { document.querySelectorAll(".stat .statValue.skeleton, .stat .statHint.skeleton").forEach((el) => el.classList.remove("skeleton")); const running = s.running ? "运行中" : "未运行"; setTextIfExists("statRunning", running); + const runningEl = document.getElementById("statRunning"); + if (runningEl) { + runningEl.classList.toggle("stateOk", !!s.running); + runningEl.classList.toggle("stateMuted", !s.running); + } setTextIfExists("statPid", s.pid ?? "-"); setTextIfExists("statUptime", fmtDuration(s.uptime_seconds)); setTextIfExists("statLogLen", s.log_len ?? "-"); @@ -2043,6 +2128,8 @@ window.addEventListener("DOMContentLoaded", async () => { initShotFullscreen(); initHeaderScroll(); initKeyboardShortcuts(); + initShortcutsHelp(); + startReservationsCountdownTick(); // 首屏统计数字加骨架,待第一次 pollStats 成功后移除 document.querySelectorAll(".stat .statValue").forEach((el) => { if ((el.textContent || "").trim() === "-") el.classList.add("skeleton"); diff --git a/webui/index.html b/webui/index.html index 00d583c..0857616 100644 --- a/webui/index.html +++ b/webui/index.html @@ -15,7 +15,7 @@ } catch (e) {} })(); - +
@@ -1252,6 +1252,6 @@
- + diff --git a/webui/styles.css b/webui/styles.css index c49e2e9..2f5104b 100644 --- a/webui/styles.css +++ b/webui/styles.css @@ -1132,7 +1132,21 @@ svg { border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-soft); - animation: surfaceIn var(--motion-slow) both; +} + +.panel.active { + animation: panelFadeIn 220ms cubic-bezier(0.2, 0.7, 0.2, 1); +} + +@keyframes panelFadeIn { + from { opacity: 0; transform: translateY(4px); } + to { opacity: 1; transform: translateY(0); } +} + +@media (prefers-reduced-motion: reduce) { + .panel.active { + animation: none; + } } .panel.cardLog { @@ -1489,6 +1503,18 @@ input[type="number"]::-webkit-outer-spin-button { transition: color var(--motion-fast); } +.statValue.stateOk { + color: var(--success); +} + +.statValue.stateMuted { + color: var(--muted); +} + +.statValue.stateError { + color: var(--danger); +} + .statValue.hasCopy { position: relative; padding-right: 28px; @@ -2371,6 +2397,141 @@ details[open] > summary.sectionTitle::before { background-clip: padding-box; } +/* ==================== Shortcuts help overlay ==================== */ +.shortcutsOverlay { + position: fixed; + inset: 0; + z-index: 90; + display: flex; + align-items: center; + justify-content: center; + padding: 24px; + background: color-mix(in oklab, var(--bg) 70%, transparent); + backdrop-filter: blur(6px); + opacity: 0; + transition: opacity 160ms ease; +} + +.shortcutsOverlay.isVisible { + opacity: 1; +} + +.shortcutsCard { + width: min(420px, 100%); + border: 1px solid var(--border); + border-radius: var(--radius-lg); + background: var(--surface); + box-shadow: 0 16px 40px rgba(0, 0, 0, 0.18), 0 4px 12px rgba(0, 0, 0, 0.1); + overflow: hidden; + transform: translateY(8px) scale(0.98); + transition: transform 200ms cubic-bezier(0.2, 0.7, 0.2, 1); +} + +:root[data-theme="dark"] .shortcutsCard { + box-shadow: 0 16px 40px rgba(0, 0, 0, 0.6), 0 4px 12px rgba(0, 0, 0, 0.5); +} + +.shortcutsOverlay.isVisible .shortcutsCard { + transform: translateY(0) scale(1); +} + +.shortcutsHeader { + display: flex; + align-items: center; + justify-content: space-between; + padding: 12px 14px 10px; + border-bottom: 1px solid var(--border); + background: var(--surface-soft); +} + +.shortcutsTitle { + font-size: 13px; + font-weight: 600; + color: var(--text-strong); + letter-spacing: var(--tracking-tight); +} + +.shortcutsClose { + display: inline-flex; + align-items: center; + justify-content: center; + width: 24px; + height: 24px; + padding: 0; + border: 0; + border-radius: var(--radius-sm); + color: var(--muted); + background: transparent; + cursor: pointer; + transition: color var(--motion-fast), background var(--motion-fast); +} + +.shortcutsClose:hover { + color: var(--text); + background: var(--surface-muted); +} + +.shortcutsList { + display: grid; + gap: 2px; + padding: 8px; +} + +.shortcutsRow { + display: flex; + align-items: center; + justify-content: space-between; + gap: 12px; + padding: 8px 10px; + border-radius: var(--radius-sm); + font-size: var(--text-sm); + color: var(--text); +} + +.shortcutsRow:hover { + background: var(--surface-soft); +} + +.shortcutsDesc { + color: var(--text); +} + +.shortcutsKeys { + display: inline-flex; + align-items: center; + gap: 4px; +} + +.shortcutsKeys kbd { + display: inline-flex; + align-items: center; + justify-content: center; + min-width: 22px; + height: 22px; + padding: 0 6px; + border: 1px solid var(--border-strong); + border-bottom-width: 2px; + border-radius: 5px; + background: var(--surface); + color: var(--text-strong); + font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; + font-size: 11px; + letter-spacing: 0.04em; +} + +.shortcutsPlus { + color: var(--muted-soft); + font-size: 10px; + font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; +} + +@media (prefers-reduced-motion: reduce) { + .shortcutsOverlay, + .shortcutsCard { + transition: none; + } +} + /* ==================== App footer ==================== */ .appFooter { display: flex;