From cea5f1df45a37955ab32e111cac719d7db96b02c Mon Sep 17 00:00:00 2001 From: Codex Date: Thu, 21 May 2026 09:02:55 +0800 Subject: [PATCH] =?UTF-8?q?=E7=B2=BE=E4=BF=AE=20WebUI=20=E7=AC=AC=E5=8D=81?= =?UTF-8?q?=E4=B9=9D=E8=BD=AE=EF=BC=9Asticky=20elevation=20+=20toggle=20sw?= =?UTF-8?q?itch=20+=20=E6=AD=A5=E8=BF=9B=E6=8C=89=E9=92=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - sectionTitle sticky 真贴顶时(IntersectionObserver + sentinel rootMargin -65px)加 .isStuck 类,浮起 0 6px 12px 阴影 - 关键开关升级为 toggle switch:.check.isToggle 把 input[type=checkbox] 渲染成 32×18 滑块(slider 配 14×14 圆点 + 0.18 阴影);3 个总控开关接入:infinite_loop_enabled / yanghao_enabled / yanghao_enable_actions / yanghao_only - fmtDuration 改 mono 格式:HH:MM:SS / MM:SS(padStart),适配 tabular-nums - 自绘 number stepper:所有 .input[type=number] 自动包 .numStepperWrap,hover/focus 时右侧浮现 ▲▼ 微按钮(18×12 双按钮组),调用 stepUp/stepDown + 派发 input/change;inline2 内不加避免连体冲突 - cache-bust v21 → v22 --- webui/app.js | 64 ++++++++++++++++++++++-- webui/index.html | 12 ++--- webui/styles.css | 123 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 190 insertions(+), 9 deletions(-) diff --git a/webui/app.js b/webui/app.js index af6a12d..225fdb3 100644 --- a/webui/app.js +++ b/webui/app.js @@ -555,6 +555,23 @@ function initShotFullscreen() { }); } +function initStickySectionShadow() { + // 当 .sectionTitle 真正贴住 sticky top 时加 .isStuck 类 + const titles = Array.from(document.querySelectorAll(".sectionTitle")) + .filter((el) => !el.matches(".cardTitle, summary, summary *")); + if (!titles.length || !("IntersectionObserver" in window)) return; + const io = new IntersectionObserver( + (entries) => { + for (const e of entries) { + // intersectionRatio < 1 && top 已到达 sentinel:贴住状态 + e.target.classList.toggle("isStuck", e.intersectionRatio < 1 && e.boundingClientRect.top <= 65); + } + }, + { threshold: [1], rootMargin: "-65px 0px 0px 0px" } + ); + titles.forEach((t) => io.observe(t)); +} + function initShortcutsHelp() { const isMac = /Mac|iPhone|iPad|iPod/i.test(navigator.platform || navigator.userAgent || ""); const mod = isMac ? "⌘" : "Ctrl"; @@ -843,6 +860,44 @@ function renderActionsLog() { el.scrollTop = el.scrollHeight; } +function attachNumberSteppers() { + // 给所有 .input[type=number] 包裹 .numStepperWrap + 添加 +/- 按钮 + const SVG_UP = ''; + const SVG_DOWN = ''; + document.querySelectorAll('input.input[type="number"]').forEach((input) => { + if (input.dataset.stepperBound === "1") return; + if (input.closest(".inline2")) return; // inline2 内不加,避免连体边框冲突 + input.dataset.stepperBound = "1"; + const wrap = document.createElement("div"); + wrap.className = "numStepperWrap"; + input.parentNode.insertBefore(wrap, input); + wrap.appendChild(input); + const btns = document.createElement("span"); + btns.className = "numStepperBtns"; + const up = document.createElement("button"); + up.type = "button"; + up.tabIndex = -1; + up.className = "numStepperBtn"; + up.setAttribute("aria-label", "增加"); + up.innerHTML = SVG_UP; + const down = document.createElement("button"); + down.type = "button"; + down.tabIndex = -1; + down.className = "numStepperBtn"; + down.setAttribute("aria-label", "减少"); + down.innerHTML = SVG_DOWN; + btns.append(up, down); + wrap.appendChild(btns); + const fire = (dir) => { + try { dir > 0 ? input.stepUp() : input.stepDown(); } catch (_) {} + input.dispatchEvent(new Event("input", { bubbles: true })); + input.dispatchEvent(new Event("change", { bubbles: true })); + }; + up.addEventListener("click", (e) => { e.preventDefault(); fire(1); }); + down.addEventListener("click", (e) => { e.preventDefault(); fire(-1); }); + }); +} + function fmtTime(ts) { if (!ts) return "-"; try { @@ -857,9 +912,10 @@ function fmtDuration(seconds) { const h = Math.floor(s / 3600); const m = Math.floor((s % 3600) / 60); const sec = s % 60; - if (h > 0) return `${h}小时${m}分${sec}秒`; - if (m > 0) return `${m}分${sec}秒`; - return `${sec}秒`; + const pad = (n) => String(n).padStart(2, "0"); + // mono 格式:HH:MM:SS(>1h)/ MM:SS(其他),方便 tabular-nums 对齐 + if (h > 0) return `${pad(h)}:${pad(m)}:${pad(sec)}`; + return `${pad(m)}:${pad(sec)}`; } function pollShot() { @@ -2266,6 +2322,8 @@ window.addEventListener("DOMContentLoaded", async () => { initHeaderScroll(); initKeyboardShortcuts(); initShortcutsHelp(); + initStickySectionShadow(); + attachNumberSteppers(); startReservationsCountdownTick(); // 首屏统计数字加骨架,待第一次 pollStats 成功后移除 document.querySelectorAll(".stat .statValue").forEach((el) => { diff --git a/webui/index.html b/webui/index.html index 9100389..d2891a4 100644 --- a/webui/index.html +++ b/webui/index.html @@ -15,7 +15,7 @@ } catch (e) {} })(); - +
@@ -253,7 +253,7 @@
-