feat: show precise file size with decimal (#210)
This commit is contained in:
parent
3c6206849f
commit
8a1e7674df
1 changed files with 6 additions and 2 deletions
|
@ -778,7 +778,11 @@ function formatSize(size) {
|
||||||
const sizes = ['B', 'KB', 'MB', 'GB', 'TB'];
|
const sizes = ['B', 'KB', 'MB', 'GB', 'TB'];
|
||||||
if (size == 0) return [0, "B"];
|
if (size == 0) return [0, "B"];
|
||||||
const i = parseInt(Math.floor(Math.log(size) / Math.log(1024)));
|
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) {
|
function formatDuration(seconds) {
|
||||||
|
@ -818,4 +822,4 @@ function getEncoding(contentType) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 'utf-8'
|
return 'utf-8'
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue