This commit is contained in:
杜恒
2021-05-24 15:31:17 +08:00
parent bbaa2acbb0
commit d3b101d37e
6 changed files with 12 additions and 6 deletions

View File

@@ -3,7 +3,7 @@ document.addEventListener('DOMContentLoaded', () => {
/* 转换字节 */
const bytesToSize = bytes => {
if (!bytes) return '0 B';
const k = 1024,
const k = 1000,
sizes = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'],
i = Math.floor(Math.log(bytes) / Math.log(k));
return (bytes / Math.pow(k, i)).toPrecision(3) + ' ' + sizes[i];

File diff suppressed because one or more lines are too long