From 16b3bde893c9e0fb0512f8608e8fd03ab0cc2d57 Mon Sep 17 00:00:00 2001 From: Codex Date: Thu, 21 May 2026 09:09:51 +0800 Subject: [PATCH] =?UTF-8?q?=E7=B2=BE=E4=BF=AE=20WebUI=20=E7=AC=AC=E4=BA=8C?= =?UTF-8?q?=E5=8D=81=E4=B8=80=E8=BD=AE=EF=BC=9Akbd=20=E6=8F=90=E7=A4=BA=20?= =?UTF-8?q?/=20=E6=A0=87=E9=A2=98=E5=8F=8D=E9=A6=88=20/=20=E8=B6=8B?= =?UTF-8?q?=E5=8A=BF=E7=AE=AD=E5=A4=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 关键按钮 kbd 提示:[data-kbd-mod="1"][data-kbd] 自动按平台注入 ⌘ 或 Ctrl 前缀;hover 时不透明度从 0.55 → 1;btnStart 显示 "⌘ ↵",btnSave 显示 "⌘ S";<900px 隐藏 - 页面 title 随运行状态:默认 "抖音挂机控制台",运行中前置 "● ... · 运行中" - stat 数字趋势箭头:setTextIfExists 检测数值变化方向,向 .statValue 注入 .statTrend ▲/▼ 圆形徽章 (success/danger 色),1100ms 出现 + 淡出再自动移除 - cache-bust v23 → v24 --- webui/app.js | 44 ++++++++++++++++++++++++++-- webui/index.html | 8 +++--- webui/styles.css | 74 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 119 insertions(+), 7 deletions(-) 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) {} })(); - +
@@ -37,7 +37,7 @@
- - - + diff --git a/webui/styles.css b/webui/styles.css index 4b1b50c..311a157 100644 --- a/webui/styles.css +++ b/webui/styles.css @@ -465,6 +465,40 @@ svg { box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--primary); } +/* Button kbd hint: render data-kbd badge when [data-kbd-mod] is present */ +.btn[data-kbd]::after { + display: inline-flex; + align-items: center; + justify-content: center; + margin-left: 6px; + padding: 0 6px; + height: 18px; + border: 1px solid color-mix(in oklab, currentColor 28%, transparent); + border-bottom-width: 2px; + border-radius: 4px; + color: inherit; + background: color-mix(in oklab, var(--surface) 30%, transparent); + font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; + font-size: 10px; + font-weight: 500; + letter-spacing: 0.04em; + line-height: 1; + content: attr(data-kbd-prefix) attr(data-kbd); + pointer-events: none; + opacity: 0.55; + transition: opacity var(--motion-fast); +} + +.btn[data-kbd]:hover::after { + opacity: 1; +} + +@media (max-width: 900px) { + .btn[data-kbd]::after { + display: none; + } +} + .btnIcon { display: inline-flex; flex: 0 0 16px; @@ -1728,6 +1762,46 @@ input[type="number"]::-webkit-outer-spin-button { color: var(--warning); } +.statTrend { + display: inline-flex; + align-items: center; + justify-content: center; + margin-left: 6px; + width: 14px; + height: 14px; + border-radius: 50%; + font-size: 9px; + line-height: 1; + font-weight: 700; + letter-spacing: 0; + opacity: 0; +} + +.statTrend.isUp { + color: var(--success); + background: color-mix(in oklab, var(--success) 14%, transparent); +} + +.statTrend.isDown { + color: var(--danger); + background: color-mix(in oklab, var(--danger) 14%, transparent); +} + +.statTrend.isFading { + animation: statTrendFade 1100ms ease forwards; +} + +@keyframes statTrendFade { + 0% { opacity: 0; transform: translateY(2px) scale(0.85); } + 20% { opacity: 1; transform: translateY(0) scale(1); } + 80% { opacity: 1; transform: translateY(0) scale(1); } + 100% { opacity: 0; transform: translateY(-2px) scale(0.95); } +} + +@media (prefers-reduced-motion: reduce) { + .statTrend.isFading { animation: none; opacity: 1; } +} + .statValue.hasCopy { position: relative; padding-right: 28px;