feat: show precise file size with decimal (#210)

This commit is contained in:
Jesse Hu 2023-05-18 12:01:02 +08:00 committed by GitHub
parent 3c6206849f
commit 8a1e7674df
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -778,7 +778,11 @@ function formatSize(size) {
const sizes = ['B', 'KB', 'MB', 'GB', 'TB'];
if (size == 0) return [0, "B"];
const i = parseInt(Math.floor(Math.log(size) / Math.log(1024)));
return [Math.round(size / Math.pow(1024, i), 2), sizes[i]];
ratio = 1
if (i >= 3) {
ratio = 100
}
return [Math.round(size * ratio / Math.pow(1024, i), 2) / ratio, sizes[i]];
}
function formatDuration(seconds) {