file finished todo

This commit is contained in:
dlarmor
2023-03-15 10:07:27 +08:00
parent d46812483f
commit b6e3a583ff
3 changed files with 23 additions and 30 deletions

View File

@ -137,3 +137,12 @@ export const generateUUID = () => {
return (c === 'x' ? random : (random & 0x3) | 0x8).toString(16)
})
}
export const fileSizeFormatter = (row) => {
const unitArr = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']
const srcSize = parseFloat(row.size)
const index = Math.floor(Math.log(srcSize) / Math.log(1024))
const size = srcSize / Math.pow(1024, index)
const sizeStr = size.toFixed(2) //保留的小数位数
return sizeStr + ' ' + unitArr[index]
}