Show download speed in MB/s instead of Mbps.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
f1e927726c
commit
e841997399
1 changed files with 9 additions and 7 deletions
|
|
@ -86,13 +86,15 @@ function targetLabel(t?: string): string {
|
|||
return TARGET_OPTIONS.find((o) => o.id === t)?.label || t || "4K";
|
||||
}
|
||||
|
||||
function formatMbps(bps: number | null | undefined): string {
|
||||
function formatSpeed(bps: number | null | undefined): string {
|
||||
if (bps == null || bps < 0) return "—";
|
||||
if (bps === 0) return "0 Mbps";
|
||||
const mbps = (bps * 8) / 1_000_000;
|
||||
if (mbps >= 10) return `${mbps.toFixed(0)} Mbps`;
|
||||
if (mbps >= 1) return `${mbps.toFixed(1)} Mbps`;
|
||||
return `${(mbps * 1000).toFixed(0)} Kbps`;
|
||||
if (bps === 0) return "0 MB/s";
|
||||
const mbs = bps / 1_000_000;
|
||||
if (mbs >= 10) return `${mbs.toFixed(1)} MB/s`;
|
||||
if (mbs >= 1) return `${mbs.toFixed(2)} MB/s`;
|
||||
const kbs = bps / 1000;
|
||||
if (kbs >= 1) return `${kbs.toFixed(0)} KB/s`;
|
||||
return `${bps.toFixed(0)} B/s`;
|
||||
}
|
||||
|
||||
function progressLabel(job: JobRow): string {
|
||||
|
|
@ -102,7 +104,7 @@ function progressLabel(job: JobRow): string {
|
|||
if (!p) return "…";
|
||||
const parts: string[] = [];
|
||||
if (p.percent != null) parts.push(`${p.percent % 1 === 0 ? p.percent.toFixed(0) : p.percent.toFixed(1)}%`);
|
||||
parts.push(formatMbps(p.speedBps));
|
||||
parts.push(formatSpeed(p.speedBps));
|
||||
return parts.join(" · ");
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue