import { X, ExternalLink } from 'lucide-react'; import { imageAPI } from '../api'; /** * 文件查看器 - 支持视频播放和文档查看 * 不依赖额外库,使用浏览器原生能力 */ function FileViewer({ file, libraryId, onClose }) { if (!file) return null; // 兼容前端的 fileType 字段和旧的 file_type 字段 const fileType = file.fileType || file.file_type || 'image'; const originalUrl = imageAPI.getOriginalUrl(libraryId, file.path); // 在浏览器中打开原始文件(交给浏览器/系统处理) const openInSystem = async () => { try { if (originalUrl) { window.open(originalUrl, '_blank'); } } catch (error) { console.error('Failed to open file in browser:', error); } }; return (
{/* 顶部工具栏 */}
{file.filename}
{/* 内容区域 */}
{fileType === 'video' && ( )} {fileType === 'audio' && (
🎵

{file.filename}

)} {fileType === 'document' && (
{file.format === 'pdf' ? (