diff --git a/webui/app.js b/webui/app.js index f083d0f..966d8ae 100644 --- a/webui/app.js +++ b/webui/app.js @@ -402,18 +402,61 @@ function initConfigSearch() { input.focus(); }); } + + // Platform-aware kbd hint label + const isMac = /Mac|iPhone|iPad|iPod/i.test(navigator.platform || navigator.userAgent || ""); + const kbdMod = $("configSearchKbdMod"); + if (kbdMod) kbdMod.textContent = isMac ? "⌘" : "Ctrl"; + + // ⌘K / Ctrl+K to focus, ESC to clear/blur + document.addEventListener("keydown", (e) => { + const mod = isMac ? e.metaKey : e.ctrlKey; + if (mod && e.key.toLowerCase() === "k") { + e.preventDefault(); + input.focus(); + input.select(); + return; + } + if (e.key === "Escape" && document.activeElement === input) { + if (input.value) { + input.value = ""; + apply(""); + } else { + input.blur(); + } + } + }); } function initTabs() { const tabButtons = Array.from(document.querySelectorAll(".tabBtn[data-target]")); const panels = Array.from(document.querySelectorAll(".panel[data-panel]")); + const sideNav = document.querySelector(".sideNav"); if (tabButtons.length === 0 || panels.length === 0) return; + const updateIndicator = (btn) => { + if (!sideNav || !btn || sideNav.offsetParent === null) return; + // 横向布局(移动端 row)下不绘制竖条 + const isRow = getComputedStyle(sideNav).flexDirection !== "column"; + if (isRow) { + sideNav.style.setProperty("--tab-indicator-opacity", "0"); + return; + } + const navRect = sideNav.getBoundingClientRect(); + const btnRect = btn.getBoundingClientRect(); + const top = (btnRect.top - navRect.top) + (btnRect.height - 16) / 2; + sideNav.style.setProperty("--tab-indicator-y", `${top}px`); + sideNav.style.setProperty("--tab-indicator-h", `16px`); + sideNav.style.setProperty("--tab-indicator-opacity", "1"); + }; + const setActive = (target) => { + let activeBtn = null; for (const btn of tabButtons) { const isActive = btn.dataset.target === target; btn.classList.toggle("active", isActive); btn.setAttribute("aria-selected", isActive ? "true" : "false"); + if (isActive) activeBtn = btn; } for (const panel of panels) { const isActive = panel.dataset.panel === target; @@ -421,6 +464,7 @@ function initTabs() { panel.classList.toggle("active", isActive); } document.body.dataset.activePanel = target || ""; + updateIndicator(activeBtn); }; for (const btn of tabButtons) { @@ -429,6 +473,22 @@ function initTabs() { const defaultTarget = tabButtons.find(b => b.classList.contains("active"))?.dataset.target || tabButtons[0].dataset.target; setActive(defaultTarget); + + // 窗口尺寸变化或字体加载完成时重新计算位置 + let resizeTimer; + window.addEventListener("resize", () => { + clearTimeout(resizeTimer); + resizeTimer = setTimeout(() => { + const cur = document.querySelector(".tabBtn.active[data-target]"); + if (cur) updateIndicator(cur); + }, 80); + }); + if (document.fonts && document.fonts.ready) { + document.fonts.ready.then(() => { + const cur = document.querySelector(".tabBtn.active[data-target]"); + if (cur) updateIndicator(cur); + }); + } } function classifyLogLine(line) { @@ -1439,12 +1499,15 @@ async function pollReservations() { reservations.forEach((item, idx) => { const card = document.createElement("div"); card.className = "reservationItem"; - + const now = Date.now() / 1000; const future_ts = item.future_ts || 0; const remain = Math.max(0, Math.floor(future_ts - now)); const remainStr = remain > 0 ? `${Math.floor(remain / 60)}分${remain % 60}秒后` : "已到开奖时间"; - + // 60s 内开奖:高亮提醒 + if (remain > 0 && remain <= 60) card.classList.add("isImminent"); + else if (remain === 0) card.classList.add("isDue"); + card.innerHTML = `
#${idx + 1} diff --git a/webui/index.html b/webui/index.html index 7a9e24a..d6ecc10 100644 --- a/webui/index.html +++ b/webui/index.html @@ -15,17 +15,18 @@ } catch (e) {} })(); - +
@@ -191,6 +192,7 @@ + @@ -1231,6 +1233,6 @@
- + diff --git a/webui/styles.css b/webui/styles.css index 5b964e2..1f5372b 100644 --- a/webui/styles.css +++ b/webui/styles.css @@ -266,8 +266,8 @@ svg { } .brandMark svg { - width: 18px; - height: 18px; + width: 22px; + height: 22px; } .title { @@ -358,7 +358,46 @@ svg { .btn.isBusy { cursor: progress; - opacity: 0.7; + opacity: 0.85; + pointer-events: none; + position: relative; +} + +.btn.isBusy .btnIcon { + visibility: hidden; +} + +.btn.isBusy::before { + position: absolute; + left: 12px; + top: 50%; + width: 14px; + height: 14px; + margin-top: -7px; + content: ""; + border-radius: 50%; + border: 2px solid currentColor; + border-top-color: transparent; + opacity: 0.85; + animation: btnSpin 720ms linear infinite; +} + +.btn.isBusy:not(:has(.btnIcon))::before { + position: relative; + left: 0; + top: 0; + margin: 0 6px 0 0; + display: inline-block; +} + +@keyframes btnSpin { + to { transform: rotate(360deg); } +} + +@media (prefers-reduced-motion: reduce) { + .btn.isBusy::before { + animation-duration: 2s; + } } .btn:focus-visible, @@ -808,7 +847,7 @@ svg { .workspaceSearch input { width: 100%; min-height: 32px; - padding: 0 30px 0 30px; + padding: 0 64px 0 30px; border: 1px solid var(--border-strong); border-radius: var(--radius-md); color: var(--text); @@ -867,6 +906,38 @@ svg { background: var(--surface-muted); } +.workspaceSearchKbd { + position: absolute; + right: 30px; + top: 50%; + transform: translateY(-50%); + display: inline-flex; + align-items: center; + gap: 3px; + height: 18px; + padding: 0 5px; + border: 1px solid var(--border-strong); + border-radius: 4px; + background: var(--surface); + color: var(--muted); + font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; + font-size: 10px; + letter-spacing: 0.04em; + pointer-events: none; + transition: opacity var(--motion-fast); +} + +.workspaceSearch:focus-within .workspaceSearchKbd, +.workspaceSearch input:not(:placeholder-shown) ~ .workspaceSearchKbd { + opacity: 0; +} + +@media (max-width: 640px) { + .workspaceSearchKbd { + display: none; + } +} + .row.isSearchHidden, .sectionTitle.isSearchHidden { display: none !important; @@ -895,6 +966,38 @@ svg { box-shadow: 0 1px 0 var(--hairline) inset; } +/* Floating active indicator: a thin vertical bar that slides between tabs. + Position is driven by --tab-indicator-y / --tab-indicator-h CSS vars + updated from JS whenever the active tab changes. */ +.sideNav { + position: relative; + --tab-indicator-y: 6px; + --tab-indicator-h: 14px; + --tab-indicator-opacity: 0; +} + +.sideNav::before { + position: absolute; + left: 4px; + top: var(--tab-indicator-y); + width: 2px; + height: var(--tab-indicator-h); + content: ""; + border-radius: 2px; + background: var(--primary); + opacity: var(--tab-indicator-opacity); + transition: top 220ms cubic-bezier(0.2, 0.7, 0.2, 1), + height 220ms cubic-bezier(0.2, 0.7, 0.2, 1), + opacity var(--motion-fast); + pointer-events: none; +} + +@media (prefers-reduced-motion: reduce) { + .sideNav::before { + transition: opacity var(--motion-fast); + } +} + .tabBtn { position: relative; display: flex; @@ -917,18 +1020,8 @@ svg { } .tabBtn::before { - position: absolute; - left: 4px; - top: 50%; - width: 2px; - height: 14px; - margin-top: -7px; - content: ""; - border-radius: 2px; - background: var(--primary); - opacity: 0; - transform: scaleY(0.4); - transition: opacity var(--motion-fast), transform var(--motion-fast); + /* Disabled: sideNav now owns the floating active indicator. */ + display: none; } .tabBtn:hover { @@ -943,8 +1036,7 @@ svg { } .tabBtn.active::before { - opacity: 1; - transform: scaleY(1); + display: none; } .tabIcon { @@ -1602,6 +1694,40 @@ select.input { box-shadow: var(--shadow-soft); } +.reservationItem.isImminent { + border-color: var(--warning); + background: color-mix(in oklab, var(--warning-soft) 60%, var(--surface)); + animation: imminentPulse 1.6s ease-in-out infinite; +} + +.reservationItem.isImminent .reservationValue { + border-color: var(--warning); + background: var(--warning); + color: var(--on-primary); +} + +.reservationItem.isDue { + border-color: var(--danger); + background: color-mix(in oklab, var(--danger-soft) 50%, var(--surface)); +} + +.reservationItem.isDue .reservationValue { + border-color: var(--danger); + background: var(--danger); + color: var(--on-primary); +} + +@keyframes imminentPulse { + 0%, 100% { box-shadow: 0 0 0 0 color-mix(in oklab, var(--warning) 35%, transparent); } + 50% { box-shadow: 0 0 0 6px transparent; } +} + +@media (prefers-reduced-motion: reduce) { + .reservationItem.isImminent { + animation: none; + } +} + .reservationHeader { display: flex; align-items: center;