|
|
@@ -368,10 +368,14 @@ export const downloadFileBase64 = (path, name) => {
|
|
|
|
|
|
/**
|
|
|
* 格式化文件大小
|
|
|
- * @param {number} bytes - 文件大小(字节)
|
|
|
+ * @param {number|null|undefined} bytes - 文件大小(字节)
|
|
|
* @returns {string} 格式化后的文件大小
|
|
|
*/
|
|
|
export const formatFileSize = (bytes) => {
|
|
|
+ // 处理null、undefined、非数字值
|
|
|
+ if (bytes === null || bytes === undefined || isNaN(bytes) || bytes < 0) {
|
|
|
+ return '-/-'
|
|
|
+ }
|
|
|
if (bytes === 0) return '0 B'
|
|
|
const k = 1024
|
|
|
const sizes = ['B', 'KB', 'MB', 'GB', 'TB']
|