精修 WebUI 第二十一轮:kbd 提示 / 标题反馈 / 趋势箭头
- 关键按钮 kbd 提示:[data-kbd-mod="1"][data-kbd] 自动按平台注入 ⌘ 或 Ctrl 前缀;hover 时不透明度从 0.55 → 1;btnStart 显示 "⌘ ↵",btnSave 显示 "⌘ S";<900px 隐藏 - 页面 title 随运行状态:默认 "抖音挂机控制台",运行中前置 "● ... · 运行中" - stat 数字趋势箭头:setTextIfExists 检测数值变化方向,向 .statValue 注入 .statTrend ▲/▼ 圆形徽章 (success/danger 色),1100ms 出现 + 淡出再自动移除 - cache-bust v23 → v24
This commit is contained in:
1 parent
df96f25eba
commit
16b3bde893
3 files changed
+119
-7
No files matched your search
+41
-3
@@ -555,6 +555,15 @@ function initShotFullscreen() {
|
||||
});
|
||||
}
|
||||
|
||||
function applyKbdHints() {
|
||||
// 给 [data-kbd-mod="1"] 的按钮自动注入平台对应的修饰键前缀
|
||||
const isMac = /Mac|iPhone|iPad|iPod/i.test(navigator.platform || navigator.userAgent || "");
|
||||
const prefix = isMac ? "⌘ " : "Ctrl ";
|
||||
document.querySelectorAll('[data-kbd-mod="1"]').forEach((el) => {
|
||||
el.setAttribute("data-kbd-prefix", prefix);
|
||||
});
|
||||
}
|
||||
|
||||
function initStickySectionShadow() {
|
||||
// 当 .sectionTitle 真正贴住 sticky top 时加 .isStuck 类
|
||||
const titles = Array.from(document.querySelectorAll(".sectionTitle"))
|
||||
@@ -993,21 +1002,44 @@ function setTextIfExists(id, text) {
|
||||
const el = $(id);
|
||||
if (!el) return;
|
||||
const next = String(text ?? "-");
|
||||
// 仅取文本节点(跳过子元素如 .copyBtn)来比较和读取当前值
|
||||
// 仅取文本节点(跳过子元素如 .copyBtn / .statTrend)来比较和读取当前值
|
||||
const getTextOnly = (node) => {
|
||||
let s = "";
|
||||
for (const ch of node.childNodes) if (ch.nodeType === Node.TEXT_NODE) s += ch.textContent;
|
||||
return s;
|
||||
};
|
||||
const prev = getTextOnly(el);
|
||||
// 仅对 statValue 有效:值变化时短暂高亮
|
||||
// 仅对 statValue 有效:值变化时短暂高亮 + 趋势箭头
|
||||
if (el.classList.contains("statValue") && prev !== next && next !== "-") {
|
||||
el.classList.remove("isFlash");
|
||||
void el.offsetWidth;
|
||||
el.classList.add("isFlash");
|
||||
setTimeout(() => el.classList.remove("isFlash"), 700);
|
||||
// 数字字段才显示趋势
|
||||
const prevNum = Number(prev);
|
||||
const nextNum = Number(next);
|
||||
if (Number.isFinite(prevNum) && Number.isFinite(nextNum) && prevNum !== nextNum) {
|
||||
let trend = el.querySelector(".statTrend");
|
||||
if (!trend) {
|
||||
trend = document.createElement("span");
|
||||
trend.className = "statTrend";
|
||||
el.appendChild(trend);
|
||||
}
|
||||
const isUp = nextNum > prevNum;
|
||||
trend.textContent = isUp ? "▲" : "▼";
|
||||
trend.classList.toggle("isUp", isUp);
|
||||
trend.classList.toggle("isDown", !isUp);
|
||||
trend.classList.remove("isFading");
|
||||
void trend.offsetWidth;
|
||||
trend.classList.add("isFading");
|
||||
// 1s 后自动消失
|
||||
clearTimeout(trend._fadeTimer);
|
||||
trend._fadeTimer = setTimeout(() => {
|
||||
if (trend) trend.remove();
|
||||
}, 1100);
|
||||
}
|
||||
}
|
||||
// 替换:保留所有非文本子节点(如 .copyBtn),仅更新文本
|
||||
// 替换:保留所有非文本子节点(如 .copyBtn / .statTrend),仅更新文本
|
||||
for (const ch of Array.from(el.childNodes)) {
|
||||
if (ch.nodeType === Node.TEXT_NODE) ch.remove();
|
||||
}
|
||||
@@ -2202,6 +2234,11 @@ async function pollStats() {
|
||||
s.running ? RUN_TONE.running : RUN_TONE.idle
|
||||
);
|
||||
document.body.classList.toggle("is-running", !!s.running);
|
||||
// 页面标题随运行状态更新
|
||||
try {
|
||||
const baseTitle = "抖音挂机控制台";
|
||||
document.title = s.running ? `● ${baseTitle} · 运行中` : baseTitle;
|
||||
} catch (_) {}
|
||||
setTextIfExists("topLogState", UI_COPY.overview.logLines(s.log_len));
|
||||
setTextIfExists("topLogMeta", UI_COPY.overview.lastLog(s.last_log_ts));
|
||||
|
||||
@@ -2343,6 +2380,7 @@ window.addEventListener("DOMContentLoaded", async () => {
|
||||
initShortcutsHelp();
|
||||
initStickySectionShadow();
|
||||
attachNumberSteppers();
|
||||
applyKbdHints();
|
||||
startReservationsCountdownTick();
|
||||
// 首屏统计数字加骨架,待第一次 pollStats 成功后移除
|
||||
document.querySelectorAll(".stat .statValue").forEach((el) => {
|
||||
|
||||
+4
-4
@@ -16,7 +16,7 @@
|
||||
} catch (e) {}
|
||||
})();
|
||||
</script>
|
||||
<link rel="stylesheet" href="styles.css?v=console-20260520-theme-v23" />
|
||||
<link rel="stylesheet" href="styles.css?v=console-20260520-theme-v24" />
|
||||
</head>
|
||||
<body>
|
||||
<div class="app">
|
||||
@@ -37,7 +37,7 @@
|
||||
</div>
|
||||
<div class="header-actions">
|
||||
<div class="actionGroup primaryActions">
|
||||
<button id="btnStart" class="btn btnPrimary">
|
||||
<button id="btnStart" class="btn btnPrimary" data-kbd-mod="1" data-kbd="↵">
|
||||
<span class="btnIcon" aria-hidden="true">
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M7 4v16l13-8z"/></svg>
|
||||
</span>
|
||||
@@ -81,7 +81,7 @@
|
||||
</span>
|
||||
加载配置
|
||||
</button>
|
||||
<button id="btnSave" class="btn btnPrimary">
|
||||
<button id="btnSave" class="btn btnPrimary" data-kbd-mod="1" data-kbd="S">
|
||||
<span class="btnIcon" aria-hidden="true">
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M19 21H5a2 2 0 0 1-2-2V7a2 2 0 0 1 2-2h11l5 5v9a2 2 0 0 1-2 2z"/><path d="M17 21v-8H7v8"/><path d="M7 3v5h8"/></svg>
|
||||
</span>
|
||||
@@ -1260,6 +1260,6 @@
|
||||
<svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="m18 15-6-6-6 6"/></svg>
|
||||
</button>
|
||||
|
||||
<script src="app.js?v=console-20260520-theme-v23"></script>
|
||||
<script src="app.js?v=console-20260520-theme-v24"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -465,6 +465,40 @@ svg {
|
||||
box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--primary);
|
||||
}
|
||||
|
||||
/* Button kbd hint: render data-kbd badge when [data-kbd-mod] is present */
|
||||
.btn[data-kbd]::after {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
margin-left: 6px;
|
||||
padding: 0 6px;
|
||||
height: 18px;
|
||||
border: 1px solid color-mix(in oklab, currentColor 28%, transparent);
|
||||
border-bottom-width: 2px;
|
||||
border-radius: 4px;
|
||||
color: inherit;
|
||||
background: color-mix(in oklab, var(--surface) 30%, transparent);
|
||||
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
|
||||
font-size: 10px;
|
||||
font-weight: 500;
|
||||
letter-spacing: 0.04em;
|
||||
line-height: 1;
|
||||
content: attr(data-kbd-prefix) attr(data-kbd);
|
||||
pointer-events: none;
|
||||
opacity: 0.55;
|
||||
transition: opacity var(--motion-fast);
|
||||
}
|
||||
|
||||
.btn[data-kbd]:hover::after {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
@media (max-width: 900px) {
|
||||
.btn[data-kbd]::after {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
.btnIcon {
|
||||
display: inline-flex;
|
||||
flex: 0 0 16px;
|
||||
@@ -1728,6 +1762,46 @@ input[type="number"]::-webkit-outer-spin-button {
|
||||
color: var(--warning);
|
||||
}
|
||||
|
||||
.statTrend {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
margin-left: 6px;
|
||||
width: 14px;
|
||||
height: 14px;
|
||||
border-radius: 50%;
|
||||
font-size: 9px;
|
||||
line-height: 1;
|
||||
font-weight: 700;
|
||||
letter-spacing: 0;
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
.statTrend.isUp {
|
||||
color: var(--success);
|
||||
background: color-mix(in oklab, var(--success) 14%, transparent);
|
||||
}
|
||||
|
||||
.statTrend.isDown {
|
||||
color: var(--danger);
|
||||
background: color-mix(in oklab, var(--danger) 14%, transparent);
|
||||
}
|
||||
|
||||
.statTrend.isFading {
|
||||
animation: statTrendFade 1100ms ease forwards;
|
||||
}
|
||||
|
||||
@keyframes statTrendFade {
|
||||
0% { opacity: 0; transform: translateY(2px) scale(0.85); }
|
||||
20% { opacity: 1; transform: translateY(0) scale(1); }
|
||||
80% { opacity: 1; transform: translateY(0) scale(1); }
|
||||
100% { opacity: 0; transform: translateY(-2px) scale(0.95); }
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.statTrend.isFading { animation: none; opacity: 1; }
|
||||
}
|
||||
|
||||
.statValue.hasCopy {
|
||||
position: relative;
|
||||
padding-right: 28px;
|
||||
|
||||
Reference in new issue
Block a user