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 @@
-