diff --git a/webui/app.js b/webui/app.js index 0227aa3..a12beda 100644 --- a/webui/app.js +++ b/webui/app.js @@ -555,6 +555,15 @@ function initShotFullscreen() { }); } +function applyKbdHints() { + // 给 [data-kbd-mod="1"] 的按钮自动注入平台对应的修饰键前缀 + const isMac = /Mac|iPhone|iPad|iPod/i.test(navigator.platform || navigator.userAgent || ""); + const prefix = isMac ? "⌘ " : "Ctrl "; + document.querySelectorAll('[data-kbd-mod="1"]').forEach((el) => { + el.setAttribute("data-kbd-prefix", prefix); + }); +} + function initStickySectionShadow() { // 当 .sectionTitle 真正贴住 sticky top 时加 .isStuck 类 const titles = Array.from(document.querySelectorAll(".sectionTitle")) @@ -993,21 +1002,44 @@ function setTextIfExists(id, text) { const el = $(id); if (!el) return; const next = String(text ?? "-"); - // 仅取文本节点(跳过子元素如 .copyBtn)来比较和读取当前值 + // 仅取文本节点(跳过子元素如 .copyBtn / .statTrend)来比较和读取当前值 const getTextOnly = (node) => { let s = ""; for (const ch of node.childNodes) if (ch.nodeType === Node.TEXT_NODE) s += ch.textContent; return s; }; const prev = getTextOnly(el); - // 仅对 statValue 有效:值变化时短暂高亮 + // 仅对 statValue 有效:值变化时短暂高亮 + 趋势箭头 if (el.classList.contains("statValue") && prev !== next && next !== "-") { el.classList.remove("isFlash"); void el.offsetWidth; el.classList.add("isFlash"); setTimeout(() => el.classList.remove("isFlash"), 700); + // 数字字段才显示趋势 + const prevNum = Number(prev); + const nextNum = Number(next); + if (Number.isFinite(prevNum) && Number.isFinite(nextNum) && prevNum !== nextNum) { + let trend = el.querySelector(".statTrend"); + if (!trend) { + trend = document.createElement("span"); + trend.className = "statTrend"; + el.appendChild(trend); + } + const isUp = nextNum > prevNum; + trend.textContent = isUp ? "▲" : "▼"; + trend.classList.toggle("isUp", isUp); + trend.classList.toggle("isDown", !isUp); + trend.classList.remove("isFading"); + void trend.offsetWidth; + trend.classList.add("isFading"); + // 1s 后自动消失 + clearTimeout(trend._fadeTimer); + trend._fadeTimer = setTimeout(() => { + if (trend) trend.remove(); + }, 1100); + } } - // 替换:保留所有非文本子节点(如 .copyBtn),仅更新文本 + // 替换:保留所有非文本子节点(如 .copyBtn / .statTrend),仅更新文本 for (const ch of Array.from(el.childNodes)) { if (ch.nodeType === Node.TEXT_NODE) ch.remove(); } @@ -2202,6 +2234,11 @@ async function pollStats() { s.running ? RUN_TONE.running : RUN_TONE.idle ); document.body.classList.toggle("is-running", !!s.running); + // 页面标题随运行状态更新 + try { + const baseTitle = "抖音挂机控制台"; + document.title = s.running ? `● ${baseTitle} · 运行中` : baseTitle; + } catch (_) {} setTextIfExists("topLogState", UI_COPY.overview.logLines(s.log_len)); setTextIfExists("topLogMeta", UI_COPY.overview.lastLog(s.last_log_ts)); @@ -2343,6 +2380,7 @@ window.addEventListener("DOMContentLoaded", async () => { initShortcutsHelp(); initStickySectionShadow(); attachNumberSteppers(); + applyKbdHints(); startReservationsCountdownTick(); // 首屏统计数字加骨架,待第一次 pollStats 成功后移除 document.querySelectorAll(".stat .statValue").forEach((el) => { diff --git a/webui/index.html b/webui/index.html index 8aa97dd..cdc3a8f 100644 --- a/webui/index.html +++ b/webui/index.html @@ -16,7 +16,7 @@ } catch (e) {} })(); - +