补全 fileSizeFormatter 的注释

This commit is contained in:
YunaiV 2023-03-15 20:35:18 +08:00
parent 07d79e3286
commit 11d4e2ea17

View File

@ -138,9 +138,18 @@ export const generateUUID = () => {
})
}
export const fileSizeFormatter = (row) => {
/**
* element plus Formatter
*
* @param row
* @param column
* @param cellValue
*/
// @ts-ignore
export const fileSizeFormatter = (row, column, cellValue) => {
const fileSize = cellValue
const unitArr = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']
const srcSize = parseFloat(row.size)
const srcSize = parseFloat(fileSize)
const index = Math.floor(Math.log(srcSize) / Math.log(1024))
const size = srcSize / Math.pow(1024, index)
const sizeStr = size.toFixed(2) //保留的小数位数