精修 WebUI 第十六轮:滚动顶按钮 / 连体按钮组 / 图表 hover / 徽章
- 滚动 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
This commit is contained in:
1 parent
94e8d37d18
commit
51d8d53a2b
3 files changed
+248
-8
No files matched your search
+93
-3
@@ -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(`<span><i class="timelineDotMark" style="background:${TIMELINE_STROKES[k]?.stroke || 'var(--primary)'};opacity:${TIMELINE_STROKES[k]?.opacity ?? 1}"></i>${SERIES_LABEL[k] || k}</span><b>${v}</b>`);
|
||||
}
|
||||
if (total === 0) lines.push(`<span class="hint">无事件</span>`);
|
||||
tip.innerHTML = `<div class="timelineTipTime">${fmtTimeOf(i)}</div><div class="timelineTipBody">${lines.join("")}</div>`;
|
||||
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";
|
||||
|
||||
+11
-5
@@ -15,7 +15,7 @@
|
||||
} catch (e) {}
|
||||
})();
|
||||
</script>
|
||||
<link rel="stylesheet" href="styles.css?v=console-20260520-theme-v18" />
|
||||
<link rel="stylesheet" href="styles.css?v=console-20260520-theme-v19" />
|
||||
</head>
|
||||
<body>
|
||||
<div class="app">
|
||||
@@ -224,9 +224,11 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="rowActions">
|
||||
<button id="btnWifiEnable" class="btn" type="button">启用 WiFi ADB</button>
|
||||
<button id="btnWifiConnect" class="btn" type="button">连接</button>
|
||||
<button id="btnWifiDisconnect" class="btn" type="button">断开</button>
|
||||
<div class="btnGroup" role="group" aria-label="WiFi ADB 操作">
|
||||
<button id="btnWifiEnable" class="btn" type="button">启用 WiFi ADB</button>
|
||||
<button id="btnWifiConnect" class="btn" type="button">连接</button>
|
||||
<button id="btnWifiDisconnect" class="btn" type="button">断开</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="hint" id="wifiStatus">先用 USB 设备启用 TCP/IP,再按 IP 连接。</div>
|
||||
</div>
|
||||
@@ -1252,6 +1254,10 @@
|
||||
</footer>
|
||||
</div>
|
||||
|
||||
<script src="app.js?v=console-20260520-theme-v18"></script>
|
||||
<button id="btnScrollTop" type="button" class="scrollTopBtn" aria-label="回到顶部" data-tooltip="回到顶部" data-tooltip-pos="top" hidden>
|
||||
<svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="m18 15-6-6-6 6"/></svg>
|
||||
</button>
|
||||
|
||||
<script src="app.js?v=console-20260520-theme-v19"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -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;
|
||||
|
||||
Reference in new issue
Block a user