完整横条显示并对容量尺寸单位优化自动识别
This commit is contained in:
@@ -221,3 +221,11 @@ export async function copyToClipboard(text: string): Promise<boolean> {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function bytesToSize(bytes: number) {
|
||||
const sizes = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB']
|
||||
if (bytes === 0)
|
||||
return '0B'
|
||||
const i = parseInt(String(Math.floor(Math.log(bytes) / Math.log(1024))))
|
||||
return `${(bytes / 1024 ** i).toFixed(1)} ${sizes[i]}`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user