diff --git a/webui/app.js b/webui/app.js index 3e35bf2..dc7dc37 100644 --- a/webui/app.js +++ b/webui/app.js @@ -459,6 +459,8 @@ function attachCopyButtons() { btn.type = "button"; btn.className = "copyBtn"; btn.setAttribute("aria-label", "复制"); + btn.setAttribute("data-tooltip", "复制"); + btn.setAttribute("data-tooltip-pos", "bottom"); btn.innerHTML = ''; btn.addEventListener("click", async (e) => { e.stopPropagation(); @@ -487,6 +489,39 @@ function attachCopyButtons() { } } +function initKeyboardShortcuts() { + const isMac = /Mac|iPhone|iPad|iPod/i.test(navigator.platform || navigator.userAgent || ""); + document.addEventListener("keydown", (e) => { + const mod = isMac ? e.metaKey : e.ctrlKey; + if (!mod) return; + const key = e.key.toLowerCase(); + // ⌘S / Ctrl+S → 保存配置 + if (key === "s") { + e.preventDefault(); + const btn = document.getElementById("btnSave"); + if (btn && !btn.disabled) btn.click(); + return; + } + // ⌘Enter / Ctrl+Enter → 启动运行 + if (key === "enter") { + e.preventDefault(); + const btn = document.getElementById("btnStart"); + if (btn && !btn.disabled) btn.click(); + return; + } + }); +} + +function initHeaderScroll() { + const header = document.querySelector(".header"); + if (!header) return; + const onScroll = () => { + header.classList.toggle("isScrolled", window.scrollY > 8); + }; + window.addEventListener("scroll", onScroll, { passive: true }); + onScroll(); +} + function initShotFullscreen() { const btn = document.getElementById("btnShotFullscreen"); const img = document.getElementById("liveShot"); @@ -2006,6 +2041,8 @@ window.addEventListener("DOMContentLoaded", async () => { initFooter(); attachCopyButtons(); initShotFullscreen(); + initHeaderScroll(); + initKeyboardShortcuts(); // 首屏统计数字加骨架,待第一次 pollStats 成功后移除 document.querySelectorAll(".stat .statValue").forEach((el) => { if ((el.textContent || "").trim() === "-") el.classList.add("skeleton"); diff --git a/webui/index.html b/webui/index.html index 9d34664..bd0a727 100644 --- a/webui/index.html +++ b/webui/index.html @@ -15,7 +15,7 @@ } catch (e) {} })(); - +