fix(05): slip file display
This commit is contained in:
parent
8d87368a7c
commit
2abdc093a1
2 changed files with 25 additions and 8 deletions
|
|
@ -445,4 +445,17 @@ export function commaInput(text: string): string {
|
|||
return integerPart + (decimalPart ? `.${decimalPart}` : '');
|
||||
}
|
||||
|
||||
export function convertFileSize(size: number): string {
|
||||
if (size === undefined) return 'Unknow size';
|
||||
|
||||
const units = ['B', 'KB', 'MB', 'GB', 'TB'];
|
||||
|
||||
let i = 0;
|
||||
let sizeNumber = typeof size === 'string' ? parseFloat(size) : size;
|
||||
while (sizeNumber >= 1024 && i++ < units.length - 1) {
|
||||
sizeNumber /= 1024;
|
||||
}
|
||||
return sizeNumber.toFixed(2) + ' ' + units[i];
|
||||
}
|
||||
|
||||
export default useUtilsStore;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue