修复泄露IP的严重BUG

This commit is contained in:
CN-JS-HuiBai
2026-04-04 22:43:42 +08:00
parent 0914881d26
commit e2dbf06601
3 changed files with 58 additions and 15 deletions

View File

@@ -380,8 +380,15 @@ class MetricChart {
ctx.textAlign = 'right';
let label = '';
if (this.unit === 'B/s') {
label = window.formatBandwidth ? window.formatBandwidth(v) : v.toFixed(0);
if (this.unit === 'B/s' || this.unit === 'B') {
const isRate = this.unit === 'B/s';
if (window.formatBandwidth && isRate) {
label = window.formatBandwidth(v);
} else if (window.formatBytes) {
label = window.formatBytes(v) + (isRate ? '/s' : '');
} else {
label = v.toFixed(0) + this.unit;
}
} else {
label = (v >= 1000 ? (v / 1000).toFixed(1) + 'k' : v.toFixed(v < 10 && v > 0 ? 1 : 0)) + this.unit;
}