Files
FileCodeBoxFronted2026/src/utils/convert.ts
T
2024-11-25 18:30:14 +08:00

11 lines
318 B
TypeScript

// 存储单位转换
export const getStorageUnit = (value: number) => {
if (value >= 1024 * 1024 * 1024) {
return Math.round(value / (1024 * 1024 * 1024)) + 'GB'
} else if (value >= 1024 * 1024) {
return Math.round(value / (1024 * 1024)) + 'MB'
} else {
return Math.round(value / 1024) + 'KB'
}
}