mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2025-04-20 05:52:24 +00:00
revert changes
This commit is contained in:
parent
99cadf7652
commit
514c4909a4
1 changed files with 18 additions and 12 deletions
|
@ -1,19 +1,25 @@
|
||||||
const ONE_KB = 1024;
|
const ONE_KB = 1024;
|
||||||
const units = ["B", "KB", "MB", "GB", "TB", "PB"];
|
const ONE_MB = ONE_KB * 1024;
|
||||||
|
const ONE_GB = ONE_MB * 1024;
|
||||||
|
const ONE_TB = ONE_GB * 1024;
|
||||||
|
const ONE_PB = ONE_TB * 1024;
|
||||||
|
|
||||||
function sizeFormat(size) {
|
function sizeFormat(size) {
|
||||||
if (size < 0) {
|
if (size <= 0) return "0 B";
|
||||||
return "0 B";
|
|
||||||
|
if (size < ONE_KB) {
|
||||||
|
return size.toFixed(0) + " B";
|
||||||
|
} else if (size < ONE_MB) {
|
||||||
|
return (size / ONE_KB).toFixed(2) + " KB";
|
||||||
|
} else if (size < ONE_GB) {
|
||||||
|
return (size / ONE_MB).toFixed(2) + " MB";
|
||||||
|
} else if (size < ONE_TB) {
|
||||||
|
return (size / ONE_GB).toFixed(2) + " GB";
|
||||||
|
} else if (size < ONE_PB) {
|
||||||
|
return (size / ONE_TB).toFixed(2) + " TB";
|
||||||
|
} else {
|
||||||
|
return (size / ONE_PB).toFixed(2) + " PB";
|
||||||
}
|
}
|
||||||
|
|
||||||
let index = 0;
|
|
||||||
|
|
||||||
while (size >= ONE_KB && index < units.length - 1) {
|
|
||||||
size /= ONE_KB;
|
|
||||||
index++;
|
|
||||||
}
|
|
||||||
|
|
||||||
return `${size.toFixed(index === 0 ? 0 : 2)} ${units[index]}`;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function cpuSpeedFormat(speed) {
|
function cpuSpeedFormat(speed) {
|
||||||
|
|
Loading…
Reference in a new issue