From 51d8d53a2b902c74f68a3df271f9c1196d66dfc1 Mon Sep 17 00:00:00 2001 From: Codex Date: Thu, 21 May 2026 08:49:21 +0800 Subject: [PATCH] =?UTF-8?q?=E7=B2=BE=E4=BF=AE=20WebUI=20=E7=AC=AC=E5=8D=81?= =?UTF-8?q?=E5=85=AD=E8=BD=AE=EF=BC=9A=E6=BB=9A=E5=8A=A8=E9=A1=B6=E6=8C=89?= =?UTF-8?q?=E9=92=AE=20/=20=E8=BF=9E=E4=BD=93=E6=8C=89=E9=92=AE=E7=BB=84?= =?UTF-8?q?=20/=20=E5=9B=BE=E8=A1=A8=20hover=20/=20=E5=BE=BD=E7=AB=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 滚动 floating 按钮:scrollY > 240 时右下方显示,毛玻璃圆形,平滑滚回顶部;移动端调高避让 toast - WiFi ADB 操作改 .btnGroup 连体组合:共享圆角、中间无双边、focus z-index 抬起 - timeline 图加 hover 十字线 + tooltip:crosshair 跟随光标 snap 到最近 bin,浮层显示该 bin 的所有系列与时间,无事件显示空状态 - tabBtn[data-badge] 数字徽章:active 时反色 primary;预约数据更新时同步预约 tab 的徽章 - cache-bust v18 → v19 --- webui/app.js | 96 ++++++++++++++++++++++++++++++- webui/index.html | 16 ++++-- webui/styles.css | 144 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 248 insertions(+), 8 deletions(-) diff --git a/webui/app.js b/webui/app.js index 29e07d5..a7ea931 100644 --- a/webui/app.js +++ b/webui/app.js @@ -516,11 +516,17 @@ function initKeyboardShortcuts() { function initHeaderScroll() { const header = document.querySelector(".header"); - if (!header) return; + const scrollTop = document.getElementById("btnScrollTop"); const onScroll = () => { - header.classList.toggle("isScrolled", window.scrollY > 8); + if (header) header.classList.toggle("isScrolled", window.scrollY > 8); + if (scrollTop) scrollTop.toggleAttribute("hidden", window.scrollY < 240); }; window.addEventListener("scroll", onScroll, { passive: true }); + if (scrollTop) { + scrollTop.addEventListener("click", () => { + window.scrollTo({ top: 0, behavior: "smooth" }); + }); + } onScroll(); } @@ -599,6 +605,14 @@ function initShortcutsHelp() { }); } +function updateTabBadge(target, count) { + const btn = document.querySelector(`.tabBtn[data-target="${target}"]`); + if (!btn) return; + const n = Math.max(0, Number(count) || 0); + if (n > 0) btn.setAttribute("data-badge", n > 99 ? "99+" : String(n)); + else btn.removeAttribute("data-badge"); +} + function startReservationsCountdownTick() { // 每秒 tick 更新预约卡倒计时与高亮类,无需等待 stats 轮询 setInterval(() => { @@ -1195,11 +1209,85 @@ function renderTimeline(containerId, timeline) { svg.appendChild(p); } + // Crosshair hover layer:垂直线 + 当前 bin 的 dot 圆 + tooltip + const NS = "http://www.w3.org/2000/svg"; + const crossLine = document.createElementNS(NS, "line"); + crossLine.setAttribute("y1", String(padT)); + crossLine.setAttribute("y2", String(H - padB)); + crossLine.setAttribute("stroke", "var(--text)"); + crossLine.setAttribute("stroke-opacity", "0.25"); + crossLine.setAttribute("stroke-dasharray", "2 3"); + crossLine.setAttribute("pointer-events", "none"); + crossLine.setAttribute("visibility", "hidden"); + svg.appendChild(crossLine); + // 容器(外层 root)作为相对定位锚点 + root.style.position = "relative"; + + const tip = document.createElement("div"); + tip.className = "timelineTip"; + tip.hidden = true; + root.appendChild(tip); + + const fmtTimeOf = (i) => { + if (!startTs || !binSec) return ""; + try { return new Date((startTs + i * binSec) * 1000).toLocaleTimeString(); } catch { return ""; } + }; + const SERIES_LABEL = { + fudai_open_detail: "打开详情", + fudai_attend_ok: "参与成功", + fudai_attend_fail: "参与失败", + fudai_result_win: "中奖", + fudai_result_no_win: "未中奖", + fudai_skip: "跳过", + switch_room: "切换直播间", + }; + + const onMove = (ev) => { + const rect = svg.getBoundingClientRect(); + const xRatio = (ev.clientX - rect.left) / rect.width; + if (xRatio < 0 || xRatio > 1) return; + const xCoord = padL + (W - padL - padR) * xRatio; + // 找最近的 bin + let i = Math.round(((xCoord - padL) / Math.max(1, W - padL - padR)) * (bins - 1)); + if (i < 0) i = 0; else if (i >= bins) i = bins - 1; + const xOnAxis = xAt(i); + crossLine.setAttribute("x1", String(xOnAxis)); + crossLine.setAttribute("x2", String(xOnAxis)); + crossLine.setAttribute("visibility", "visible"); + + // 生成 tip 内容 + const lines = []; + let total = 0; + for (const k of TIMELINE_SERIES_KEYS) { + const arr = Array.isArray(series[k]) ? series[k] : []; + const v = Number(arr[i]) || 0; + total += v; + if (v > 0) lines.push(`${SERIES_LABEL[k] || k}${v}`); + } + if (total === 0) lines.push(`无事件`); + tip.innerHTML = `
${fmtTimeOf(i)}
${lines.join("")}
`; + tip.hidden = false; + + // tip 位置:根据当前 svg 实际宽度比例换算到 root 内 px + const actualX = (xOnAxis / W) * rect.width; + let leftPx = actualX + 8; + if (leftPx + 160 > rect.width) leftPx = actualX - 168; + if (leftPx < 0) leftPx = 4; + tip.style.left = `${Math.max(0, leftPx)}px`; + tip.style.top = `${rect.height * 0.06}px`; + }; + const onLeave = () => { + crossLine.setAttribute("visibility", "hidden"); + tip.hidden = true; + }; + svg.addEventListener("mousemove", onMove); + svg.addEventListener("mouseleave", onLeave); + root.appendChild(svg); const legend = document.createElement("div"); legend.className = "hint"; - legend.textContent = "图例:实线/虚线区分同色不同事件"; + legend.textContent = "图例:实线/虚线区分同色不同事件 · 鼠标悬停查看明细"; root.appendChild(legend); } @@ -1831,6 +1919,8 @@ async function pollReservations() { `; container.appendChild(info); + updateTabBadge("reservations", reservations.length); + if (reservations.length === 0) { const hint = document.createElement("div"); hint.className = "hint"; diff --git a/webui/index.html b/webui/index.html index ce56e02..da42991 100644 --- a/webui/index.html +++ b/webui/index.html @@ -15,7 +15,7 @@ } catch (e) {} })(); - +
@@ -224,9 +224,11 @@
- - - +
+ + + +
先用 USB 设备启用 TCP/IP,再按 IP 连接。
@@ -1252,6 +1254,10 @@ - + + + diff --git a/webui/styles.css b/webui/styles.css index a10ea1a..29c5749 100644 --- a/webui/styles.css +++ b/webui/styles.css @@ -1155,6 +1155,24 @@ svg { text-overflow: ellipsis; } +.tabBtn[data-badge]:not([data-badge="0"])::after { + margin-left: auto; + padding: 1px 6px; + border-radius: 99px; + background: var(--surface-muted); + color: var(--muted); + font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; + font-size: 10px; + font-variant-numeric: tabular-nums; + line-height: 1.4; + content: attr(data-badge); +} + +.tabBtn.active[data-badge]:not([data-badge="0"])::after { + background: var(--primary); + color: var(--on-primary); +} + .panels { min-width: 0; max-width: var(--panel-max); @@ -1659,6 +1677,63 @@ input[type="number"]::-webkit-outer-spin-button { display: block; } +.timelineTip { + position: absolute; + z-index: 5; + display: grid; + gap: 6px; + min-width: 140px; + max-width: 200px; + padding: 8px 10px; + border: 1px solid var(--border); + border-radius: var(--radius-sm); + background: var(--surface); + box-shadow: 0 8px 22px rgba(0, 0, 0, 0.12); + color: var(--text); + font-size: var(--text-xs); + font-variant-numeric: tabular-nums; + pointer-events: none; + backdrop-filter: blur(8px); +} + +:root[data-theme="dark"] .timelineTip { + box-shadow: 0 8px 22px rgba(0, 0, 0, 0.55); +} + +.timelineTipTime { + color: var(--muted); + font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; + font-size: 10px; + letter-spacing: 0.04em; +} + +.timelineTipBody { + display: grid; + grid-template-columns: 1fr auto; + align-items: center; + gap: 4px 10px; +} + +.timelineTipBody span { + display: inline-flex; + align-items: center; + gap: 6px; + color: var(--text); +} + +.timelineTipBody b { + color: var(--text-strong); + font-weight: 600; + text-align: right; +} + +.timelineDotMark { + display: inline-block; + width: 8px; + height: 8px; + border-radius: 2px; +} + .barRow { display: grid; grid-template-columns: minmax(78px, 0.9fr) minmax(80px, 2fr) 48px; @@ -2324,6 +2399,75 @@ details[open] > summary.sectionTitle::before { } } +/* Connected button group: shared border, no doubled middle border */ +.btnGroup { + display: inline-flex; + align-items: stretch; + isolation: isolate; +} + +.btnGroup > .btn { + border-radius: 0; + margin-left: -1px; +} + +.btnGroup > .btn:first-child { + border-top-left-radius: var(--radius-md); + border-bottom-left-radius: var(--radius-md); + margin-left: 0; +} + +.btnGroup > .btn:last-child { + border-top-right-radius: var(--radius-md); + border-bottom-right-radius: var(--radius-md); +} + +.btnGroup > .btn:hover, +.btnGroup > .btn:focus-visible { + z-index: 1; +} + +/* Scroll-to-top floating button */ +.scrollTopBtn { + position: fixed; + right: 20px; + bottom: 70px; + z-index: 70; + display: inline-flex; + align-items: center; + justify-content: center; + width: 36px; + height: 36px; + padding: 0; + border: 1px solid var(--border); + border-radius: 50%; + background: color-mix(in oklab, var(--surface) 80%, transparent); + color: var(--muted); + cursor: pointer; + box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1); + backdrop-filter: blur(10px); + transition: opacity 180ms ease, transform 180ms ease, color var(--motion-fast), + border-color var(--motion-fast), background var(--motion-fast); +} + +.scrollTopBtn[hidden] { + display: none !important; +} + +.scrollTopBtn:hover { + color: var(--text); + border-color: var(--hover-border); + background: var(--surface); + transform: translateY(-2px); +} + +@media (max-width: 640px) { + .scrollTopBtn { + right: 12px; + bottom: 80px; + } +} + /* Device select wrapper with status dot */ .deviceSelectWrap { position: relative;