精修 WebUI 第六轮:交互精致度
- 配置搜索加 ⌘K / Ctrl+K 快捷键聚焦 + ESC 清空/失焦;右侧带 kbd 提示徽章(输入或聚焦时自动隐藏;移动端不显示);自动按平台显示 ⌘ 或 Ctrl - 按钮 .isBusy 状态加旋转 spinner(隐藏图标),禁用 pointer-events - 即将开奖预约(剩余 ≤60s)加 isImminent 类:warning 边框 + 微脉动 + value pill 反白;已到时间加 isDue(danger 边框 + 反白) - brand logo 重做:圆角方形容器 + 内嵌播放三角 + 装饰圆点,更具品牌识别度 - 侧边导航 active 指示条改为 sideNav::before 浮动滑块,CSS var 控制 Y/H,切换 tab 时 220ms 滑动;resize/字体加载完成自动重算位置;横向布局自动隐藏 - cache-bust v8 → v9
This commit is contained in:
1 parent
96cba09c49
commit
07700c24d9
3 files changed
+217
-26
No files matched your search
+65
-2
@@ -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 = `
|
||||
<div class="reservationHeader">
|
||||
<span class="reservationIndex">#${idx + 1}</span>
|
||||
|
||||
+8
-6
@@ -15,17 +15,18 @@
|
||||
} catch (e) {}
|
||||
})();
|
||||
</script>
|
||||
<link rel="stylesheet" href="styles.css?v=console-20260520-theme-v8" />
|
||||
<link rel="stylesheet" href="styles.css?v=console-20260520-theme-v9" />
|
||||
</head>
|
||||
<body>
|
||||
<div class="app">
|
||||
<header class="header commandBar">
|
||||
<div class="brandBlock">
|
||||
<div class="brandMark" aria-hidden="true">
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
||||
<path d="M9 18V5l12-2v13"/>
|
||||
<circle cx="6" cy="18" r="3"/>
|
||||
<circle cx="18" cy="16" r="3"/>
|
||||
<svg viewBox="0 0 32 32" fill="none">
|
||||
<rect x="3" y="3" width="26" height="26" rx="7" fill="currentColor" opacity="0.18"/>
|
||||
<rect x="3" y="3" width="26" height="26" rx="7" stroke="currentColor" stroke-width="1.5"/>
|
||||
<path d="M13 10.5v11l9-5.5z" fill="currentColor"/>
|
||||
<circle cx="22" cy="10" r="2" fill="currentColor"/>
|
||||
</svg>
|
||||
</div>
|
||||
<div>
|
||||
@@ -191,6 +192,7 @@
|
||||
<svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="11" cy="11" r="7"/><path d="m21 21-4.3-4.3"/></svg>
|
||||
</span>
|
||||
<input id="configSearch" type="search" placeholder="搜索配置项 (按标签 / 提示文本)" autocomplete="off" />
|
||||
<kbd class="workspaceSearchKbd" aria-hidden="true"><span id="configSearchKbdMod">Ctrl</span> K</kbd>
|
||||
<button id="configSearchClear" type="button" class="workspaceSearchClear" aria-label="清空搜索" hidden>
|
||||
<svg viewBox="0 0 24 24" width="12" height="12" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg>
|
||||
</button>
|
||||
@@ -1231,6 +1233,6 @@
|
||||
</main>
|
||||
</div>
|
||||
|
||||
<script src="app.js?v=console-20260520-theme-v8"></script>
|
||||
<script src="app.js?v=console-20260520-theme-v9"></script>
|
||||
</body>
|
||||
</html>
|
||||
+144
-18
@@ -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;
|
||||
|
||||
Reference in new issue
Block a user