优化Web端日志导航与GUI配置

This commit is contained in:
Codex committed 2026-05-20 20:23:32 +08:00
1 parent 674ede76ee
commit 6c73f6e414
3 files changed
+1803 -495

No files matched your search

+196 -59
View File
@@ -1,3 +1,90 @@
const UI_LIMITS = Object.freeze({
runLogMaxLines: 50000,
runLogMaxChars: 200000,
actionsLogMaxLines: 5000,
scrollBottomThresholdPx: 5,
screenshotPollMs: 1500,
logPollMs: 800,
statsPollMs: 1200,
});
const UI_CLASS = Object.freeze({
busy: "isBusy",
clickable: "isClickable",
collapsed: "isCollapsed",
listCollapsed: "isListCollapsed",
reservationHeader: "reservationHeader",
reservationBody: "reservationBody",
reservationsList: "reservationsList",
shotEmpty: "isShotEmpty",
statusRunning: "statusRunning",
statusIdle: "statusIdle",
statusError: "statusError",
});
const RUN_TONE = Object.freeze({
running: "running",
idle: "idle",
error: "error",
});
const UI_COPY = Object.freeze({
empty: "-",
device: {
autoOption: "(auto)",
autoLabel: "(auto)",
noOnline: "无在线设备",
adbReady: "ADB 已就绪",
adbMissing: "ADB 未找到",
autoOnline: (count) => `${count} 台在线 / 自动选择`,
},
runOverview: {
starting: "启动中",
startingMeta: "正在向后端发送启动请求",
failed: "启动失败",
stopping: "停止中",
stoppingMeta: "已请求后端停止运行",
meta: (pid, uptimeSeconds) => `PID ${pid ?? "-"} / 运行时长 ${fmtDuration(uptimeSeconds)}`,
},
overview: {
logLines: (count) => `${count ?? 0} 行`,
lastLog: (ts) => `最后日志 ${fmtTime(ts)}`,
fudaiState: (opened, attended) => `${opened} / ${attended}`,
fudaiMeta: (seen, wins) => `识别 ${seen} / 中奖 ${wins}`,
},
});
const TIMELINE_SERIES_KEYS = Object.freeze([
"fudai_open_detail",
"fudai_attend_ok",
"fudai_attend_fail",
"fudai_result_win",
"fudai_result_no_win",
"fudai_skip",
"switch_room",
]);
const TIMELINE_LAYOUT = Object.freeze({
width: 900,
height: 220,
paddingLeft: 36,
paddingRight: 14,
paddingTop: 10,
paddingBottom: 26,
});
const TIMELINE_STROKES = Object.freeze({
fudai_open_detail: { stroke: "var(--primary)", dash: "" },
fudai_attend_ok: { stroke: "var(--primary)", dash: "6 4" },
fudai_attend_fail: { stroke: "var(--danger)", dash: "" },
fudai_result_win: { stroke: "var(--danger)", dash: "6 4" },
fudai_result_no_win: { stroke: "var(--muted)", dash: "" },
fudai_skip: { stroke: "var(--muted)", dash: "6 4" },
switch_room: { stroke: "var(--text)", dash: "2 4" },
});
const BUSY_DISABLED_BUTTONS = new Set(["btnStart", "btnSave"]);
let logIdx = 0;
let pollTimer = null;
let statsTimer = null;
@@ -8,7 +95,7 @@ let emptyResponseCount = 0; // 连续空响应计数(用于检测索引卡住
// 双日志缓冲与过滤
let runLogBuffer = [];
let runLogFilter = "";
const runLogMaxLines = 50000;
const runLogMaxLines = UI_LIMITS.runLogMaxLines;
let runLogMode = 'filter'; // 'filter' or 'search'
let runSearchResultsBuffer = [];
@@ -16,7 +103,8 @@ let runSearchActive = false;
let actionsLogBuffer = [];
let actionsLogFilter = "";
const actionsLogMaxLines = 5000;
const actionsLogMaxLines = UI_LIMITS.actionsLogMaxLines;
let deviceOverviewState = { devices: [], adb: "" };
const DEFAULTS = {
// 筛选
@@ -109,6 +197,7 @@ const DEFAULTS = {
"logging.beautify_output": true,
"logging.color_output": true,
"logging.show_timestamps": true,
"logging.use_dated_logs": true,
"logging.enable_monitor": true,
"logging.compress_logs": true,
"logging.keep_days": 30,
@@ -124,6 +213,10 @@ const DEFAULTS = {
"logging.performance_tracking.enabled": true,
"logging.performance_tracking.track_function_calls": true,
"gui.theme": "litera",
"gui.realtime_status.refresh_interval_ms": 1000,
"gui.realtime_status.tail_items": 50,
log_unified_enabled: true,
log_unified_path: "logs/unified.log",
};
function $(id) { return document.getElementById(id); }
@@ -144,6 +237,7 @@ function initTabs() {
panel.toggleAttribute("hidden", !isActive);
panel.classList.toggle("active", isActive);
}
document.body.dataset.activePanel = target || "";
};
for (const btn of tabButtons) {
@@ -161,7 +255,7 @@ function appendLog(lines) {
// 记录更新前与底部的距离,用于在非底部时保持视图位置
const distanceFromBottom = log.scrollHeight - log.scrollTop - log.clientHeight;
// 是否严格位于底部(仅在几像素内视为底部),避免每次刷新都跳到底部
const wasAtBottom = distanceFromBottom < 5;
const wasAtBottom = distanceFromBottom < UI_LIMITS.scrollBottomThresholdPx;
// 性能优化:批量追加文本,减少重排次数
const newText = lines.join("\n") + "\n";
@@ -185,7 +279,7 @@ function appendLog(lines) {
}
// 性能优化:限制日志长度,避免内存溢出(保留最近较多字符以便桌面端查看)
const maxLength = 200000;
const maxLength = UI_LIMITS.runLogMaxChars;
if (log.textContent.length > maxLength) {
// 在截断文本时,保留用户原来的距离(除非用户确实在底部)
log.textContent = log.textContent.slice(-maxLength);
@@ -210,7 +304,7 @@ function renderRunLog() {
const lines = runSearchResultsBuffer || [];
const prevScrollBottom = el.scrollHeight - el.scrollTop - el.clientHeight;
el.textContent = lines.join("\n") + (lines.length ? "\n" : "");
if (prevScrollBottom < 5) el.scrollTop = el.scrollHeight; else el.scrollTop = Math.max(0, el.scrollHeight - el.clientHeight - prevScrollBottom);
if (prevScrollBottom < UI_LIMITS.scrollBottomThresholdPx) el.scrollTop = el.scrollHeight; else el.scrollTop = Math.max(0, el.scrollHeight - el.clientHeight - prevScrollBottom);
return;
}
@@ -222,7 +316,7 @@ function renderRunLog() {
const prevScrollBottom = el.scrollHeight - el.scrollTop - el.clientHeight;
el.textContent = lines.join("\n") + (lines.length ? "\n" : "");
// 尽量保持原来滚动位置;若位于底部则滚到底部
if (prevScrollBottom < 5) el.scrollTop = el.scrollHeight; else el.scrollTop = Math.max(0, el.scrollHeight - el.clientHeight - prevScrollBottom);
if (prevScrollBottom < UI_LIMITS.scrollBottomThresholdPx) el.scrollTop = el.scrollHeight; else el.scrollTop = Math.max(0, el.scrollHeight - el.clientHeight - prevScrollBottom);
}
function appendRunLogLines(lines) {
@@ -275,12 +369,14 @@ function fmtDuration(seconds) {
function pollShot() {
const img = $("liveShot");
if (!img) return;
const preview = img.closest(".preview");
// 性能优化:避免重复加载相同的图片(如果正在加载中)
if (img.dataset.loading === "true") return;
const url = `/pic/screenshot.png?t=${Date.now()}`;
img.dataset.loading = "true";
if (preview) preview.classList.remove(UI_CLASS.shotEmpty);
img.src = url;
const status = $("liveShotStatus");
@@ -293,18 +389,27 @@ function startShotPolling() {
const img = $("liveShot");
const status = $("liveShotStatus");
if (img) {
const preview = img.closest(".preview");
const syncShotEmpty = () => {
if (!preview) return;
preview.classList.toggle(UI_CLASS.shotEmpty, img.complete && img.naturalWidth === 0);
};
syncShotEmpty();
img.addEventListener("load", () => {
img.dataset.loading = "false";
if (preview) preview.classList.remove(UI_CLASS.shotEmpty);
if (status) status.textContent = `已更新:${new Date().toLocaleTimeString()}`;
});
img.addEventListener("error", () => {
img.dataset.loading = "false";
if (preview) preview.classList.add(UI_CLASS.shotEmpty);
if (status) status.textContent = "暂无截图(等待脚本生成 pic/screenshot.png)";
});
setTimeout(syncShotEmpty, 0);
}
// 性能优化:截图轮询间隔从 900ms 调整为 1500ms,减少服务器压力
shotTimer = setInterval(pollShot, 1500);
shotTimer = setInterval(pollShot, UI_LIMITS.screenshotPollMs);
}
function setTextIfExists(id, text) {
@@ -313,6 +418,36 @@ function setTextIfExists(id, text) {
el.textContent = String(text ?? "-");
}
function setButtonBusy(id, busy) {
const btn = $(id);
if (!btn) return;
btn.classList.toggle(UI_CLASS.busy, !!busy);
btn.toggleAttribute("aria-busy", !!busy);
if (BUSY_DISABLED_BUTTONS.has(id)) btn.disabled = !!busy;
}
function setRunOverview(state, meta, tone) {
setTextIfExists("topRunState", state || UI_COPY.empty);
setTextIfExists("topRunMeta", meta || UI_COPY.empty);
const dot = $("topRunDot");
if (!dot) return;
dot.classList.remove(UI_CLASS.statusRunning, UI_CLASS.statusIdle, UI_CLASS.statusError);
dot.classList.add(tone === RUN_TONE.running ? UI_CLASS.statusRunning : tone === RUN_TONE.error ? UI_CLASS.statusError : UI_CLASS.statusIdle);
}
function updateDeviceOverview() {
const devices = Array.isArray(deviceOverviewState.devices) ? deviceOverviewState.devices : [];
const selected = selectedDeviceId();
if (selected) {
setTextIfExists("topDeviceState", selected);
} else if (devices.length > 0) {
setTextIfExists("topDeviceState", UI_COPY.device.autoOnline(devices.length));
} else {
setTextIfExists("topDeviceState", UI_COPY.device.noOnline);
}
setTextIfExists("topAdbState", deviceOverviewState.adb ? UI_COPY.device.adbReady : UI_COPY.device.adbMissing);
}
function clearEl(el) {
while (el && el.firstChild) el.removeChild(el.firstChild);
}
@@ -452,18 +587,8 @@ function renderTimeline(containerId, timeline) {
return;
}
const keys = [
"fudai_open_detail",
"fudai_attend_ok",
"fudai_attend_fail",
"fudai_result_win",
"fudai_result_no_win",
"fudai_skip",
"switch_room",
];
let maxY = 0;
for (const k of keys) {
for (const k of TIMELINE_SERIES_KEYS) {
const arr = Array.isArray(series[k]) ? series[k] : [];
for (const v of arr) maxY = Math.max(maxY, Number(v) || 0);
}
@@ -475,18 +600,18 @@ function renderTimeline(containerId, timeline) {
return;
}
const W = 900;
const H = 220;
const padL = 36;
const padR = 14;
const padT = 10;
const padB = 26;
const W = TIMELINE_LAYOUT.width;
const H = TIMELINE_LAYOUT.height;
const padL = TIMELINE_LAYOUT.paddingLeft;
const padR = TIMELINE_LAYOUT.paddingRight;
const padT = TIMELINE_LAYOUT.paddingTop;
const padB = TIMELINE_LAYOUT.paddingBottom;
const svg = document.createElementNS("http://www.w3.org/2000/svg", "svg");
svg.setAttribute("viewBox", `0 0 ${W} ${H}`);
svg.setAttribute("width", "100%");
svg.setAttribute("height", String(H));
svg.style.display = "block";
svg.classList.add("timelineSvg");
const axis = document.createElementNS("http://www.w3.org/2000/svg", "path");
axis.setAttribute("d", `M ${padL} ${H - padB} L ${W - padR} ${H - padB}`);
@@ -529,17 +654,7 @@ function renderTimeline(containerId, timeline) {
svg.appendChild(mkText((padL + (W - padR)) / 2, H - 8, fmtShort(startTs + Math.floor(bins / 2) * binSec), "middle"));
svg.appendChild(mkText(W - padR, H - 8, fmtShort(startTs + (bins - 1) * binSec), "end"));
const strokes = {
fudai_open_detail: { stroke: "var(--primary)", dash: "" },
fudai_attend_ok: { stroke: "var(--primary)", dash: "6 4" },
fudai_attend_fail: { stroke: "var(--danger)", dash: "" },
fudai_result_win: { stroke: "var(--danger)", dash: "6 4" },
fudai_result_no_win: { stroke: "var(--muted)", dash: "" },
fudai_skip: { stroke: "var(--muted)", dash: "6 4" },
switch_room: { stroke: "var(--text)", dash: "2 4" },
};
for (const k of keys) {
for (const k of TIMELINE_SERIES_KEYS) {
const arr = Array.isArray(series[k]) ? series[k] : [];
if (arr.length === 0) continue;
let d = "";
@@ -551,9 +666,9 @@ function renderTimeline(containerId, timeline) {
const p = document.createElementNS("http://www.w3.org/2000/svg", "path");
p.setAttribute("d", d);
p.setAttribute("fill", "none");
p.setAttribute("stroke", strokes[k]?.stroke || "var(--primary)");
p.setAttribute("stroke", TIMELINE_STROKES[k]?.stroke || "var(--primary)");
p.setAttribute("stroke-width", "2");
if (strokes[k]?.dash) p.setAttribute("stroke-dasharray", strokes[k].dash);
if (TIMELINE_STROKES[k]?.dash) p.setAttribute("stroke-dasharray", TIMELINE_STROKES[k].dash);
p.setAttribute("stroke-linecap", "round");
p.setAttribute("stroke-linejoin", "round");
svg.appendChild(p);
@@ -598,7 +713,7 @@ async function refreshDevices() {
const optAuto = document.createElement("option");
optAuto.value = "";
optAuto.textContent = "(auto)";
optAuto.textContent = UI_COPY.device.autoOption;
sel.appendChild(optAuto);
for (const d of devices) {
@@ -609,6 +724,8 @@ async function refreshDevices() {
}
$("adbStatus").textContent = data.adb ? `adb: ${data.adb}` : "未找到 adb.exe(请安装 platform-tools)";
deviceOverviewState = { devices, adb: data.adb || "" };
updateDeviceOverview();
}
function getConfigBoundElements() {
@@ -717,9 +834,14 @@ async function loadConfig() {
}
async function saveConfig() {
const cfgUpdate = collectConfigFromUI();
await apiPost("/api/config", cfgUpdate);
appendLog(["[WEB] 配置已保存到 config.json"]);
setButtonBusy("btnSave", true);
try {
const cfgUpdate = collectConfigFromUI();
await apiPost("/api/config", cfgUpdate);
appendLog(["[WEB] 配置已保存到 config.json"]);
} finally {
setButtonBusy("btnSave", false);
}
}
function selectedDeviceId() {
@@ -782,6 +904,8 @@ async function wifiDisconnect() {
}
async function startRun() {
setButtonBusy("btnStart", true);
setRunOverview(UI_COPY.runOverview.starting, UI_COPY.runOverview.startingMeta, RUN_TONE.running);
try {
const deviceId = $("device").value || "";
const yPianyi = parseInt($("y_pianyi").value || "0", 10);
@@ -836,7 +960,7 @@ async function startRun() {
return;
}
appendLog([`[WEB] 已开始运行:device=${deviceId || '(auto)'}`]);
appendLog([`[WEB] 已开始运行:device=${deviceId || UI_COPY.device.autoLabel}`]);
// 启动时自动截图
if (deviceId) {
@@ -872,10 +996,13 @@ async function startRun() {
console.error("[WEB] startRun error:", e);
const errorMsg = e.message || String(e);
appendLog([`[WEB] 启动失败: ${errorMsg}`]);
setRunOverview(UI_COPY.runOverview.failed, errorMsg, RUN_TONE.error);
// 如果是"running"错误,显示友好提示
if (errorMsg === "running" || (e.status === 409)) {
appendLog([`[WEB] 提示:已有进程在运行中,请先点击"停止"按钮`]);
}
} finally {
setButtonBusy("btnStart", false);
}
}
@@ -883,17 +1010,18 @@ async function testYanghao() {
const deviceId = $("device").value || "";
const seconds = parseInt($("yanghao_recommend_duration_seconds").value || "60", 10);
await apiPost("/api/test-yanghao", { device_id: deviceId, seconds });
appendLog([`[WEB] 已启动测试养号:device=${deviceId || '(auto)'} seconds=${seconds}`]);
appendLog([`[WEB] 已启动测试养号:device=${deviceId || UI_COPY.device.autoLabel} seconds=${seconds}`]);
}
async function testComment() {
const deviceId = $("device").value || "";
const text = "";
await apiPost("/api/test-comment", { device_id: deviceId, text });
appendLog([`[WEB] 已启动测试评论:device=${deviceId || '(auto)'}${text ? ' text=自定义' : ''}`]);
appendLog([`[WEB] 已启动测试评论:device=${deviceId || UI_COPY.device.autoLabel}${text ? ' text=自定义' : ''}`]);
}
async function stopRun() {
setRunOverview(UI_COPY.runOverview.stopping, UI_COPY.runOverview.stoppingMeta, RUN_TONE.idle);
await apiPost("/api/stop", {});
appendLog(["[WEB] 已发送停止"]);
// 重置并拉取日志,确保能看到后端的停止确认输出
@@ -1142,16 +1270,12 @@ async function pollHighValueRooms() {
// 让每条记录的 header 可点击以折叠/展开本条详情
list.appendChild(card);
try {
const header = card.querySelector('.reservationHeader');
const body = card.querySelector('.reservationBody');
const header = card.querySelector(`.${UI_CLASS.reservationHeader}`);
const body = card.querySelector(`.${UI_CLASS.reservationBody}`);
if (header && body) {
header.style.cursor = 'pointer';
header.classList.add(UI_CLASS.clickable);
header.addEventListener('click', () => {
if (body.style.display === 'none') {
body.style.display = '';
} else {
body.style.display = 'none';
}
body.classList.toggle(UI_CLASS.collapsed);
});
}
} catch (e) {
@@ -1168,12 +1292,12 @@ async function pollHighValueRooms() {
const btnExpand = $('hv_expand_all');
const btnCollapse = $('hv_collapse_all');
if (btnExpand) btnExpand.addEventListener('click', () => {
const listEl = container.querySelector('.reservationsList');
if (listEl) listEl.style.display = '';
const listEl = container.querySelector(`.${UI_CLASS.reservationsList}`);
if (listEl) listEl.classList.remove(UI_CLASS.listCollapsed);
});
if (btnCollapse) btnCollapse.addEventListener('click', () => {
const listEl = container.querySelector('.reservationsList');
if (listEl) listEl.style.display = 'none';
const listEl = container.querySelector(`.${UI_CLASS.reservationsList}`);
if (listEl) listEl.classList.add(UI_CLASS.listCollapsed);
});
} catch (e) {
// ignore
@@ -1209,12 +1333,23 @@ async function pollStats() {
const c = s.counters || {};
const getC = (k) => Number.isFinite(Number(c[k])) ? Number(c[k]) : 0;
setRunOverview(
running,
UI_COPY.runOverview.meta(s.pid, s.uptime_seconds),
s.running ? RUN_TONE.running : RUN_TONE.idle
);
document.body.classList.toggle("is-running", !!s.running);
setTextIfExists("topLogState", UI_COPY.overview.logLines(s.log_len));
setTextIfExists("topLogMeta", UI_COPY.overview.lastLog(s.last_log_ts));
setTextIfExists("statFudaiSeen", getC("fudai_seen"));
setTextIfExists("statFudaiOpen", getC("fudai_open_detail"));
setTextIfExists("statFudaiAttendOk", getC("fudai_attend_ok"));
setTextIfExists("statFudaiAttendFail", getC("fudai_attend_fail"));
setTextIfExists("statFudaiNoWin", getC("fudai_result_no_win"));
setTextIfExists("statFudaiWin", getC("fudai_result_win"));
setTextIfExists("topFudaiState", UI_COPY.overview.fudaiState(getC("fudai_open_detail"), getC("fudai_attend_ok")));
setTextIfExists("topFudaiMeta", UI_COPY.overview.fudaiMeta(getC("fudai_seen"), getC("fudai_result_win")));
setTextIfExists("statSkipValueLow", getC("fudai_skip_value_low"));
@@ -1307,7 +1442,7 @@ async function pollStats() {
function startPolling() {
if (pollTimer) clearInterval(pollTimer);
// 性能优化:日志轮询间隔从 700ms 调整为 800ms,减少服务器压力同时保持实时性
pollTimer = setInterval(pollLogs, 800);
pollTimer = setInterval(pollLogs, UI_LIMITS.logPollMs);
}
function startStatsPolling() {
@@ -1316,7 +1451,7 @@ function startStatsPolling() {
pollStats();
pollReservations();
pollHighValueRooms();
}, 1200);
}, UI_LIMITS.statsPollMs);
}
window.addEventListener("DOMContentLoaded", async () => {
@@ -1326,6 +1461,8 @@ window.addEventListener("DOMContentLoaded", async () => {
$("btnSave").addEventListener("click", async () => { await saveConfig(); });
$("btnStart").addEventListener("click", async () => { await startRun(); });
$("btnStop").addEventListener("click", async () => { await stopRun(); });
const deviceSelect = $("device");
if (deviceSelect) deviceSelect.addEventListener("change", updateDeviceOverview);
const btnForceStop = $("btnForceStop");
if (btnForceStop) btnForceStop.addEventListener("click", async () => { await forceStopRun(); });
const btnBackKey = $("btnBackKey");
+154 -70
View File
@@ -4,69 +4,102 @@
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>抖音挂机 - Web GUI</title>
<link rel="stylesheet" href="styles.css" />
<link rel="stylesheet" href="styles.css?v=console-20260520-log-split" />
</head>
<body>
<div class="app">
<header class="header">
<div>
<div class="title">抖音挂机控制台</div>
<div class="subtitle">配置与运行(纯坐标点击)</div>
<header class="header commandBar">
<div class="brandBlock">
<div class="brandMark" aria-hidden="true">控</div>
<div>
<div class="title">抖音挂机控制台</div>
<div class="subtitle">设备调度、运行控制与实时观察</div>
</div>
</div>
<div class="header-actions">
<button id="btnStart" class="btn btnPrimary">
<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>
开始运行
</button>
<button id="btnRefresh" class="btn">
<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="M21 12a9 9 0 1 1-2.64-6.36"/><path d="M21 3v6h-6"/></svg>
</span>
刷新设备
</button>
<button id="btnScreenshot" class="btn">
<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"><rect x="3" y="3" width="18" height="18" rx="2" ry="2"/><circle cx="8.5" cy="8.5" r="1.5"/><polyline points="21 15 16 10 5 21"/></svg>
</span>
截图
</button>
<button id="btnLoad" class="btn">
<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="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><path d="M7 10l5 5 5-5"/><path d="M12 15V3"/></svg>
</span>
加载配置
</button>
<button id="btnSave" class="btn btnPrimary">
<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>
保存配置
</button>
<button id="btnStop" class="btn btnDanger">
<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"><rect x="6" y="6" width="12" height="12" rx="2"/></svg>
</span>
停止
</button>
<button id="btnForceStop" class="btn btnDanger">
<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="M18 6 6 18"/><path d="m6 6 12 12"/></svg>
</span>
强制停止
</button>
<button id="btnBackKey" class="btn">
<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="m9 14-4-4 4-4"/><path d="M5 10h11a4 4 0 0 1 0 8h-1"/></svg>
</span>
返回键
</button>
<div class="actionGroup primaryActions">
<button id="btnStart" class="btn btnPrimary">
<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>
开始运行
</button>
<button id="btnStop" class="btn btnDangerSoft">
<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"><rect x="6" y="6" width="12" height="12" rx="2"/></svg>
</span>
停止
</button>
<button id="btnForceStop" class="btn btnDanger">
<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="M18 6 6 18"/><path d="m6 6 12 12"/></svg>
</span>
强制停止
</button>
</div>
<div class="actionGroup secondaryActions">
<button id="btnRefresh" class="btn btnSoft">
<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="M21 12a9 9 0 1 1-2.64-6.36"/><path d="M21 3v6h-6"/></svg>
</span>
刷新设备
</button>
<button id="btnScreenshot" class="btn btnSoft">
<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"><rect x="3" y="3" width="18" height="18" rx="2" ry="2"/><circle cx="8.5" cy="8.5" r="1.5"/><polyline points="21 15 16 10 5 21"/></svg>
</span>
截图
</button>
<button id="btnBackKey" class="btn btnSoft">
<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="m9 14-4-4 4-4"/><path d="M5 10h11a4 4 0 0 1 0 8h-1"/></svg>
</span>
返回键
</button>
<button id="btnLoad" class="btn btnGhost">
<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="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><path d="M7 10l5 5 5-5"/><path d="M12 15V3"/></svg>
</span>
加载配置
</button>
<button id="btnSave" class="btn btnPrimary">
<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>
保存配置
</button>
</div>
</div>
</header>
<main class="grid">
<section class="card cardScroll cardConfig">
<section class="overview statusStrip" aria-label="运行概览">
<article class="overviewCard overviewPrimary">
<div class="overviewLabel">运行状态</div>
<div class="overviewValue">
<span id="topRunDot" class="statusDot" aria-hidden="true"></span>
<span id="topRunState">等待启动</span>
</div>
<div class="overviewMeta" id="topRunMeta">PID - / 运行时长 -</div>
</article>
<article class="overviewCard">
<div class="overviewLabel">设备连接</div>
<div class="overviewValue" id="topDeviceState">未刷新</div>
<div class="overviewMeta" id="topAdbState">ADB 状态待检测</div>
</article>
<article class="overviewCard">
<div class="overviewLabel">福袋处理</div>
<div class="overviewValue" id="topFudaiState">0 / 0</div>
<div class="overviewMeta" id="topFudaiMeta">打开详情 / 成功参与</div>
</article>
<article class="overviewCard">
<div class="overviewLabel">日志缓存</div>
<div class="overviewValue" id="topLogState">-</div>
<div class="overviewMeta" id="topLogMeta">最后日志 -</div>
</article>
</section>
<main class="workspaceShell consoleGrid">
<aside class="card configRail">
<div class="cardTitle">
<span class="sectionIcon" aria-hidden="true">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="3"/><path d="M19.4 15a1.7 1.7 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06A1.7 1.7 0 0 0 15 19.4a1.7 1.7 0 0 0-1 .31 1.7 1.7 0 0 0-.82 1.46V21a2 2 0 0 1-4 0v-.09a1.7 1.7 0 0 0-.82-1.46 1.7 1.7 0 0 0-1-.31 1.7 1.7 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06A1.7 1.7 0 0 0 4.6 15a1.7 1.7 0 0 0-.31-1 1.7 1.7 0 0 0-1.46-.82H2a2 2 0 0 1 0-4h.09a1.7 1.7 0 0 0 1.46-.82 1.7 1.7 0 0 0 .31-1 1.7 1.7 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06A1.7 1.7 0 0 0 9 4.6a1.7 1.7 0 0 0 1-.31 1.7 1.7 0 0 0 .82-1.46V2a2 2 0 0 1 4 0v.09a1.7 1.7 0 0 0 .82 1.46 1.7 1.7 0 0 0 1 .31 1.7 1.7 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06A1.7 1.7 0 0 0 19.4 9a1.7 1.7 0 0 0 .31 1 1.7 1.7 0 0 0 1.46.82H22a2 2 0 0 1 0 4h-.09a1.7 1.7 0 0 0-1.46.82 1.7 1.7 0 0 0-.31 1z"/></svg>
@@ -74,7 +107,6 @@
配置
</div>
<div class="configLayout">
<nav class="sideNav" role="tablist" aria-label="配置分类">
<button class="tabBtn active" type="button" data-target="device" role="tab" aria-selected="true">
<span class="tabIcon" aria-hidden="true"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="7" y="2" width="10" height="20" rx="2"/><path d="M11 19h2"/></svg></span>
@@ -104,7 +136,33 @@
<span class="tabIcon" aria-hidden="true"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><path d="M12 16v-4"/><path d="M12 8h.01"/></svg></span>
<span class="tabText">调试</span>
</button>
<button class="tabBtn" type="button" data-target="monitor" role="tab" aria-selected="false">
<span class="tabIcon" aria-hidden="true"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="4" width="18" height="14" rx="2"/><path d="M8 21h8"/><path d="M12 18v3"/></svg></span>
<span class="tabText">监控</span>
</button>
<button class="tabBtn" type="button" data-target="reservations" role="tab" aria-selected="false">
<span class="tabIcon" aria-hidden="true"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 2 2 7l10 5 10-5-10-5z"/><path d="M2 17l10 5 10-5"/><path d="M2 12l10 5 10-5"/></svg></span>
<span class="tabText">预约</span>
</button>
<button class="tabBtn" type="button" data-target="runLogs" role="tab" aria-selected="false">
<span class="tabIcon" aria-hidden="true"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M4 4h16v16H4z"/><path d="M8 8h8"/><path d="M8 12h8"/><path d="M8 16h6"/></svg></span>
<span class="tabText">运行日志</span>
</button>
<button class="tabBtn" type="button" data-target="actionLogs" role="tab" aria-selected="false">
<span class="tabIcon" aria-hidden="true"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M8 6h13"/><path d="M8 12h13"/><path d="M8 18h13"/><path d="M3 6h.01"/><path d="M3 12h.01"/><path d="M3 18h.01"/></svg></span>
<span class="tabText">行为日志</span>
</button>
</nav>
</aside>
<section class="configWorkspace">
<div class="workspaceHeader">
<div>
<div class="workspaceEyebrow">Configuration</div>
<h2 class="workspaceTitle">运行策略工作区</h2>
</div>
<div class="workspaceHint">配置项按当前标签自然铺排,短页不再继承长页高度。</div>
</div>
<div class="panels">
<div class="panel active" data-panel="device" role="tabpanel">
@@ -467,7 +525,7 @@
</div>
<div class="stat">
<div class="statLabel">TraceId(请求追踪)</div>
<div id="statTraceId" class="statValue" style="font-family: monospace; font-size: 0.9em;">-</div>
<div id="statTraceId" class="statValue mono statTrace">-</div>
<div class="statHint" id="statTraceIdHint">-</div>
</div>
@@ -967,6 +1025,24 @@
<div><label class="check"><input id="logging_compress_logs" type="checkbox" data-key="logging.compress_logs" data-type="bool" /> <span>压缩旧日志</span></label></div>
<div><label class="check"><input id="logging_performance_tracking_enabled" type="checkbox" data-key="logging.performance_tracking.enabled" data-type="bool" /> <span>性能追踪</span></label></div>
</div>
<div class="row grid3">
<div><label class="check"><input id="logging_use_dated_logs" type="checkbox" data-key="logging.use_dated_logs" data-type="bool" /> <span>按日期拆分日志</span></label></div>
<div><label class="check"><input id="log_unified_enabled" type="checkbox" data-key="log_unified_enabled" data-type="bool" /> <span>写入统一日志</span></label></div>
<div>
<label class="label">统一日志路径</label>
<input id="log_unified_path" class="input" data-key="log_unified_path" data-type="str" type="text" />
</div>
</div>
<div class="row grid2">
<div>
<label class="label">实时状态刷新(ms)</label>
<input id="gui_realtime_status_refresh_interval_ms" class="input" data-key="gui.realtime_status.refresh_interval_ms" data-type="int" type="number" min="200" step="100" />
</div>
<div>
<label class="label">实时状态条数</label>
<input id="gui_realtime_status_tail_items" class="input" data-key="gui.realtime_status.tail_items" data-type="int" type="number" min="10" step="10" />
</div>
</div>
<div class="row grid3">
<div>
<label class="label">日志保留天数</label>
@@ -1030,11 +1106,9 @@
<label class="check"><input id="logging_track_function_calls" type="checkbox" data-key="logging.performance_tracking.track_function_calls" data-type="bool" /> <span>追踪函数调用</span></label>
</div>
</div>
</div>
</div>
</section>
<div class="panel monitorPanel" data-panel="monitor" role="tabpanel" hidden>
<section class="card cardShot">
<div class="cardTitle">
<span class="sectionIcon" aria-hidden="true">
@@ -1048,7 +1122,9 @@
<div class="hint" id="liveShotStatus">等待截图</div>
</section>
<section class="card cardReservations">
</div>
<section class="card cardReservations panel" data-panel="reservations" role="tabpanel" hidden>
<div class="cardTitle">
<span class="sectionIcon" aria-hidden="true">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 2L2 7l10 5 10-5-10-5z"/><path d="M2 17l10 5 10-5"/><path d="M2 12l10 5 10-5"/></svg>
@@ -1062,7 +1138,7 @@
<div class="divider"></div>
<details open>
<summary class="sectionTitle">已记录直播间(高价值)
<span style="float:right; font-weight:normal; font-size:13px; margin-left:8px">
<span class="summaryActions">
<button id="hv_expand_all" class="btn small">展开全部</button>
<button id="hv_collapse_all" class="btn small">折叠全部</button>
</span>
@@ -1073,16 +1149,15 @@
</details>
</section>
<section class="card cardLog">
<section class="card cardLog panel" data-panel="runLogs" role="tabpanel" hidden>
<div class="cardTitle">
<span class="sectionIcon" aria-hidden="true">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M4 4h16v16H4z"/><path d="M8 8h8"/><path d="M8 12h8"/><path d="M8 16h6"/></svg>
</span>
日志
运行日志
</div>
<div class="logRow">
<div class="logSection">
<div class="logSection singleLogSection">
<div class="logHeader">
<div class="logTitle">运行日志</div>
<div class="logHeaderActions">
@@ -1096,9 +1171,18 @@
</div>
</div>
<pre id="runLog" class="log"></pre>
</div>
</div>
</section>
<div class="logSection">
<section class="card cardLog panel" data-panel="actionLogs" role="tabpanel" hidden>
<div class="cardTitle">
<span class="sectionIcon" aria-hidden="true">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M8 6h13"/><path d="M8 12h13"/><path d="M8 18h13"/><path d="M3 6h.01"/><path d="M3 12h.01"/><path d="M3 18h.01"/></svg>
</span>
行为日志
</div>
<div class="logSection singleLogSection">
<div class="logHeader">
<div class="logTitle">行为日志</div>
<div class="logHeaderActions">
@@ -1107,12 +1191,12 @@
</div>
</div>
<pre id="actionsLog" class="log"></pre>
</div>
</div>
</section>
</section>
</main>
</div>
<script src="app.js"></script>
<script src="app.js?v=console-20260520-log-split"></script>
</body>
</html>
+1453 -366
View File
File diff suppressed because it is too large. Load diff