'use client' import { useState } from 'react' import { FileText, Video, Image as ImageIcon, File, Download, ExternalLink, Play, Pause, Maximize2, X, AlertCircle } from 'lucide-react' import { Button } from './Button' import { Modal } from './Modal' // 文件信息类型 export interface FileInfo { id: string fileName: string fileSize: string fileType: string // MIME type: "video/mp4", "application/pdf", etc. fileUrl: string uploadedAt?: string duration?: string // 视频时长 "02:15" thumbnail?: string // 视频缩略图 } // 根据文件名或MIME类型判断文件类别 export function getFileCategory(file: FileInfo): 'video' | 'image' | 'pdf' | 'document' | 'spreadsheet' | 'other' { const fileName = file.fileName.toLowerCase() const mimeType = file.fileType.toLowerCase() // 视频 if (mimeType.startsWith('video/') || /\.(mp4|mov|webm|avi|mkv)$/.test(fileName)) { return 'video' } // 图片 if (mimeType.startsWith('image/') || /\.(jpg|jpeg|png|gif|webp|svg)$/.test(fileName)) { return 'image' } // PDF if (mimeType === 'application/pdf' || fileName.endsWith('.pdf')) { return 'pdf' } // Word 文档 if ( mimeType.includes('word') || mimeType.includes('document') || /\.(doc|docx|txt|rtf)$/.test(fileName) ) { return 'document' } // Excel 表格 if ( mimeType.includes('sheet') || mimeType.includes('excel') || /\.(xls|xlsx|csv)$/.test(fileName) ) { return 'spreadsheet' } return 'other' } // 获取文件图标 function getFileIcon(category: ReturnType) { switch (category) { case 'video': return