数据看板使用字节代替比特

This commit is contained in:
GoEdgeLab
2021-07-11 11:09:41 +08:00
parent 8d1965d997
commit ae96474efa
4 changed files with 42 additions and 17 deletions

View File

@@ -118,18 +118,18 @@ window.teaweb = {
return bytes + "B";
}
if (bytes < 1024 * 1024) {
return (Math.ceil(bytes * 100 / 1024) / 100) + "K";
return (Math.round(bytes * 100 / 1024) / 100) + "K";
}
if (bytes < 1024 * 1024 * 1024) {
return (Math.ceil(bytes * 100 / 1024 / 1024) / 100) + "M";
return (Math.round(bytes * 100 / 1024 / 1024) / 100) + "M";
}
if (bytes < 1024 * 1024 * 1024 * 1024) {
return (Math.ceil(bytes * 100 / 1024 / 1024 / 1024) / 100) + "G";
return (Math.round(bytes * 100 / 1024 / 1024 / 1024) / 100) + "G";
}
if (bytes < 1024 * 1024 * 1024 * 1024 * 1024) {
return (Math.ceil(bytes * 100 / 1024 / 1024 / 1024 / 1024) / 100) + "T";
return (Math.round(bytes * 100 / 1024 / 1024 / 1024 / 1024) / 100) + "T";
}
return (Math.ceil(bytes * 100 / 1024 / 1024 / 1024 / 1024 / 1024) / 100) + "P";
return (Math.round(bytes * 100 / 1024 / 1024 / 1024 / 1024 / 1024) / 100) + "P";
},
formatNumber: function (x) {
return x.toString().replace(/\B(?<!\.\d*)(?=(\d{3})+(?!\d))/g, ", ");