Skip to content

Commit 800a07b

Browse files
committed
今日消耗对比改用真实扣费而非预测 (v1.15.2)
- 概览「日均消耗对比」原用 prediction.burnPerDay(近3小时速率外推的预测值), 改标题为「今日消耗对比」,数据源换成 todayUsed(当日0点至今真实扣费) - 三条 bar 之和现与「今日总消耗」KPI 完全一致,口径自洽 - tooltip 去掉误导的「/天」;todayIsEstimate 的站标 ≈ 与「历史推算」, 预计耗尽(预测)仍保留并清楚标注;空态文案改为「今日暂无消耗」 - KPI「日均消耗(估算)」保留不动,真实与预测两个口径清晰并存
1 parent b6b75f6 commit 800a07b

2 files changed

Lines changed: 19 additions & 8 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "relay-monitor",
3-
"version": "1.15.1",
3+
"version": "1.15.2",
44
"private": true,
55
"description": "监控 sub2api / new-api 中转站余额的网页面板",
66
"type": "module",

public/app.js

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ function renderDashboard() {
339339
</div>
340340
<div class="panel chart-card">
341341
<div class="chart-card-head">
342-
<div><h3>日均消耗对比</h3><div class="chart-sub">按近 48 小时消耗速度回归估算(¥/天)</div></div>
342+
<div><h3>今日消耗对比</h3><div class="chart-sub">各站当日 0 点至今实际扣费(¥)</div></div>
343343
</div>
344344
<div class="chart-wrap" id="burnChart"></div>
345345
</div>
@@ -479,20 +479,31 @@ function drawTotalChart(wrap, ov) {
479479
});
480480
}
481481

482-
// 各站日均消耗横向条形图:单一色相(对比的是数值不是身份),条端直接标数值(¥/天)
482+
// 各站「今日实际消耗」横向条形图:单一色相(对比的是数值不是身份),条端直接标数值(¥)。
483+
// 数值取当日实际扣费 todayUsed(真实数据),非预测——todayIsEstimate 为历史推算,tooltip 标 ≈。
483484
function drawBurnBars(wrap, stations) {
484485
let items = stations
485-
.map((s) => ({ name: s.name, burn: (s.prediction?.burnPerDay || 0) * rateOf(s), eta: s.prediction?.etaDays ?? null }))
486+
.map((s) => ({
487+
name: s.name,
488+
burn: (s.todayUsed || 0) * rateOf(s),
489+
est: !!s.todayIsEstimate,
490+
eta: s.prediction?.etaDays ?? null,
491+
}))
486492
.filter((x) => x.burn > 0)
487493
.sort((a, b) => b.burn - a.burn);
488494
if (!items.length) {
489-
wrap.innerHTML = '<div class="chart-empty">暂无消耗数据(需要几次查询后才能估算)</div>';
495+
wrap.innerHTML = '<div class="chart-empty">今日暂无消耗</div>';
490496
return;
491497
}
492498
if (items.length > 8) {
493499
const rest = items.slice(7);
494500
items = items.slice(0, 7);
495-
items.push({ name: `其他 ${rest.length} 个`, burn: Math.round(rest.reduce((a, x) => a + x.burn, 0) * 100) / 100, eta: null });
501+
items.push({
502+
name: `其他 ${rest.length} 个`,
503+
burn: Math.round(rest.reduce((a, x) => a + x.burn, 0) * 100) / 100,
504+
est: rest.some((x) => x.est),
505+
eta: null,
506+
});
496507
}
497508
const W = 380, rowH = 32, T = 6, B = 6, nameW = 112, valW = 66;
498509
const barMax = W - nameW - valW - 12;
@@ -510,7 +521,7 @@ function drawBurnBars(wrap, stations) {
510521
<rect class="bar-hit" data-i="${i}" x="0" y="${T + i * rowH}" width="${W}" height="${rowH}" fill="transparent"/>
511522
</g>`;
512523
}).join("");
513-
wrap.innerHTML = `<svg viewBox="0 0 ${W} ${H}" role="img" aria-label="各站日均消耗对比">${rows}</svg><div class="chart-tip" id="burnTip"></div>`;
524+
wrap.innerHTML = `<svg viewBox="0 0 ${W} ${H}" role="img" aria-label="各站今日消耗对比">${rows}</svg><div class="chart-tip" id="burnTip"></div>`;
514525

515526
const svg = wrap.querySelector("svg");
516527
const tip = wrap.querySelector("#burnTip");
@@ -519,7 +530,7 @@ function drawBurnBars(wrap, stations) {
519530
if (!hit) { tip.style.display = "none"; return; }
520531
const it = items[Number(hit.dataset.i)];
521532
tip.style.display = "block";
522-
tip.innerHTML = `<div class="t">${esc(it.name)}</div><div class="v">${cny(it.burn)}/天</div>` +
533+
tip.innerHTML = `<div class="t">${esc(it.name)}${it.est ? " · 历史推算" : ""}</div><div class="v">${it.est ? "≈ " : ""}${cny(it.burn)}</div>` +
523534
(it.eta != null ? `<div class="t">预计 ${it.eta} 天后耗尽</div>` : "");
524535
const wrapRect = wrap.getBoundingClientRect();
525536
tip.style.left = Math.min(e.clientX - wrapRect.left + 14, wrapRect.width - 150) + "px";

0 commit comments

Comments
 (0)