// 文件格式转换
export const sizeFormat = (
  number: number | string,
  start: number = 0,
  max: number = 999,
  showUnit: boolean = true,
  decimal: number = 2
) => {
  const unit = ['b', 'Kb', 'Mb', 'Gb', 'Tb']
  let limitUnitIndex = Math.min(max,  unit.length - 1)
  let unitIndex = start
  let useNumber = Number(number)
  console.log('useNumber', useNumber)
  while (useNumber >= 1024  && unitIndex < limitUnitIndex) {
    useNumber /= 1024
    unitIndex++
  }
  console.log('useNumber', useNumber)

  return `${Math.ceil(useNumber).toFixed(decimal)}${showUnit ? unit[unitIndex] : ''}`
}
