function convertBytesToUnit(bytes: number, unit = "MB"): string | number {// 定义单位转换表const units: { [key: string]: number } = {// 千字节KB: 1024,// 兆字节MB: 1024 * 1024,};// 如果给定的单位不在单位转换表中if (!units.hasOwnProperty(unit)) {// 直接返回原始字节数return bytes;}// 转换字节数为指定单位的值const convertedValue = bytes / units[unit];// 返回保留三位小数的转换值和单位return `${convertedValue.toFixed(3)} ${unit}`;}