diff --git a/webui/app.js b/webui/app.js index 5c52cd1..3e35bf2 100644 --- a/webui/app.js +++ b/webui/app.js @@ -1118,6 +1118,63 @@ function notifyApiFail() { if (_apiFailStreak >= _apiFailThreshold) setConnState("error"); } +function renderOverviewSparkline(svgId, timeline) { + const svg = document.getElementById(svgId); + if (!svg) return; + // 把 fudai_open_detail + fudai_attend_ok 两个序列合成一条迷你折线 + const series = (timeline && timeline.series) || {}; + const keys = ["fudai_open_detail", "fudai_attend_ok"]; + const arrs = keys.map((k) => Array.isArray(series[k]) ? series[k] : []); + const len = Math.max(...arrs.map((a) => a.length), 0); + if (len < 2) { + svg.innerHTML = ""; + svg.classList.remove("hasData"); + return; + } + const combined = new Array(len).fill(0); + for (const arr of arrs) { + for (let i = 0; i < arr.length; i++) combined[i] += Number(arr[i]) || 0; + } + const maxY = Math.max(1, ...combined); + // 100x24 viewBox:留 1px 边 + const W = 100, H = 24, padY = 1.5; + const xAt = (i) => (W * i) / (len - 1); + const yAt = (v) => H - padY - ((H - padY * 2) * v) / maxY; + let d = ""; + for (let i = 0; i < len; i++) { + const x = xAt(i).toFixed(2), y = yAt(combined[i]).toFixed(2); + d += (i === 0 ? "M" : " L") + x + " " + y; + } + // 渐变填充区 + const dArea = d + ` L ${W} ${H} L 0 ${H} Z`; + const NS = "http://www.w3.org/2000/svg"; + svg.setAttribute("viewBox", `0 0 ${W} ${H}`); + svg.innerHTML = ""; + // gradient defs + const defs = document.createElementNS(NS, "defs"); + const gid = svgId + "Grad"; + const grad = document.createElementNS(NS, "linearGradient"); + grad.setAttribute("id", gid); + grad.setAttribute("x1", "0"); grad.setAttribute("y1", "0"); + grad.setAttribute("x2", "0"); grad.setAttribute("y2", "1"); + grad.innerHTML = ``; + defs.appendChild(grad); + svg.appendChild(defs); + const area = document.createElementNS(NS, "path"); + area.setAttribute("d", dArea); + area.setAttribute("fill", `url(#${gid})`); + svg.appendChild(area); + const line = document.createElementNS(NS, "path"); + line.setAttribute("d", d); + line.setAttribute("fill", "none"); + line.setAttribute("stroke", "currentColor"); + line.setAttribute("stroke-width", "1.25"); + line.setAttribute("stroke-linecap", "round"); + line.setAttribute("stroke-linejoin", "round"); + svg.appendChild(line); + svg.classList.add("hasData"); +} + async function apiGet(path) { try { const res = await fetch(path, { cache: "no-store" }); @@ -1912,6 +1969,7 @@ async function pollStats() { }; renderTimeline("chartTimeline", agg.timeline); + renderOverviewSparkline("topFudaiSparkline", agg.timeline); renderBars("chartSkipReason", agg.skip_reason || {}, reasonName); renderBars("chartSwitchReason", agg.switch_reason || {}, switchName); renderBars("chartValueBuckets", agg.value_buckets || {}); diff --git a/webui/index.html b/webui/index.html index 205822f..9d34664 100644 --- a/webui/index.html +++ b/webui/index.html @@ -15,7 +15,7 @@ } catch (e) {} })(); - +
@@ -116,6 +116,7 @@
福袋处理
0 / 0
打开详情 / 成功参与
+
日志缓存
@@ -1248,6 +1249,6 @@
- + diff --git a/webui/styles.css b/webui/styles.css index e1d8e78..f9dd96a 100644 --- a/webui/styles.css +++ b/webui/styles.css @@ -602,6 +602,20 @@ svg { overflow-wrap: anywhere; } +.overviewSpark { + display: block; + width: 100%; + height: 22px; + margin-top: 8px; + color: var(--primary); + opacity: 0; + transition: opacity var(--motion); +} + +.overviewSpark.hasData { + opacity: 0.8; +} + .statusDot { position: relative; flex: 0 0 8px;