diff --git a/webui/app.js b/webui/app.js index 57bf1bb..6debab4 100644 --- a/webui/app.js +++ b/webui/app.js @@ -746,7 +746,17 @@ function initTabs() { }; for (const btn of tabButtons) { - btn.addEventListener("click", () => setActive(btn.dataset.target)); + btn.addEventListener("click", () => { + const wasActive = btn.classList.contains("active"); + setActive(btn.dataset.target); + // Trigger burst pulse on the indicator only when actually switching + if (!wasActive && sideNav) { + sideNav.classList.remove("isBurst"); + void sideNav.offsetWidth; + sideNav.classList.add("isBurst"); + setTimeout(() => sideNav.classList.remove("isBurst"), 380); + } + }); } const defaultTarget = tabButtons.find(b => b.classList.contains("active"))?.dataset.target || tabButtons[0].dataset.target; @@ -974,6 +984,13 @@ function fmtTime(ts) { } } +function fmtNum(v) { + if (v === null || typeof v === "undefined") return "-"; + const n = Number(v); + if (!Number.isFinite(n)) return String(v); + return n.toLocaleString("en-US"); +} + function fmtDuration(seconds) { const s = Math.max(0, parseInt(seconds || 0, 10)); const h = Math.floor(s / 3600); @@ -2271,7 +2288,7 @@ async function pollStats() { } setTextIfExists("statPid", s.pid ?? "-"); setTextIfExists("statUptime", fmtDuration(s.uptime_seconds)); - setTextIfExists("statLogLen", s.log_len ?? "-"); + setTextIfExists("statLogLen", fmtNum(s.log_len)); if ($("statLogCap")) { const cap = s.log_capacity ?? 2000; const len = s.log_len ?? 0; @@ -2297,12 +2314,12 @@ async function pollStats() { 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("statFudaiSeen", fmtNum(getC("fudai_seen"))); + setTextIfExists("statFudaiOpen", fmtNum(getC("fudai_open_detail"))); + setTextIfExists("statFudaiAttendOk", fmtNum(getC("fudai_attend_ok"))); + setTextIfExists("statFudaiAttendFail", fmtNum(getC("fudai_attend_fail"))); + setTextIfExists("statFudaiNoWin", fmtNum(getC("fudai_result_no_win"))); + setTextIfExists("statFudaiWin", fmtNum(getC("fudai_result_win"))); // 福袋统计语义着色 const colorize = (id, kind, n) => { const el = document.getElementById(id); @@ -2319,20 +2336,20 @@ async function pollStats() { 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")); + setTextIfExists("statSkipValueLow", fmtNum(getC("fudai_skip_value_low"))); const pLow = getC("fudai_skip_participants_low"); const pHigh = getC("fudai_skip_participants_high"); - setTextIfExists("statSkipParticipants", pLow + pHigh); + setTextIfExists("statSkipParticipants", fmtNum(pLow + pHigh)); if ($("statSkipParticipantsHint")) { $("statSkipParticipantsHint").textContent = `低:${pLow} / 高:${pHigh}`; } - setTextIfExists("statSkipContent", getC("fudai_skip_content")); + setTextIfExists("statSkipContent", fmtNum(getC("fudai_skip_content"))); const cdShort = getC("fudai_skip_countdown_short"); const cdLong = getC("fudai_skip_countdown_long"); - setTextIfExists("statSkipCountdown", cdShort + cdLong); + setTextIfExists("statSkipCountdown", fmtNum(cdShort + cdLong)); if ($("statSkipCountdownHint")) { $("statSkipCountdownHint").textContent = `短:${cdShort} / 长:${cdLong}`; } @@ -2340,13 +2357,13 @@ async function pollStats() { const fcReq = getC("fansclub_required"); const fcManual = getC("fansclub_manual_needed"); const fcUn = getC("fansclub_unresolved"); - setTextIfExists("statFansclub", fcReq); + setTextIfExists("statFansclub", fmtNum(fcReq)); if ($("statFansclubHint")) { $("statFansclubHint").textContent = `需手动:${fcManual} / 未解决:${fcUn}`; } const sw = getC("switch_room"); - setTextIfExists("statSwitchRoom", sw); + setTextIfExists("statSwitchRoom", fmtNum(sw)); if ($("statSwitchRoomHint")) { const parts = [ `无福袋:${getC("switch_room_no_fudai")}`, diff --git a/webui/index.html b/webui/index.html index d246e7e..cf35be4 100644 --- a/webui/index.html +++ b/webui/index.html @@ -19,7 +19,7 @@ } catch (e) {} })(); - +