|
@@ -107,7 +107,8 @@ export const FilesPage: React.FC = () => {
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
// 检查是否为可预览的文件类型
|
|
// 检查是否为可预览的文件类型
|
|
|
- const isPreviewable = (fileType: string) => {
|
|
|
|
|
|
|
+ const isPreviewable = (fileType: string | null) => {
|
|
|
|
|
+ if (!fileType) return false;
|
|
|
return fileType.startsWith('image/') || fileType.startsWith('video/');
|
|
return fileType.startsWith('image/') || fileType.startsWith('video/');
|
|
|
};
|
|
};
|
|
|
|
|
|
|
@@ -171,8 +172,8 @@ export const FilesPage: React.FC = () => {
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
// 格式化文件大小
|
|
// 格式化文件大小
|
|
|
- const formatFileSize = (bytes: number) => {
|
|
|
|
|
- if (bytes === 0) return '0 Bytes';
|
|
|
|
|
|
|
+ const formatFileSize = (bytes: number | null) => {
|
|
|
|
|
+ if (!bytes || bytes === 0) return '0 Bytes';
|
|
|
const k = 1024;
|
|
const k = 1024;
|
|
|
const sizes = ['Bytes', 'KB', 'MB', 'GB'];
|
|
const sizes = ['Bytes', 'KB', 'MB', 'GB'];
|
|
|
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
const i = Math.floor(Math.log(bytes) / Math.log(k));
|