'use client'; import { useCallback, useState, useEffect, useRef } from 'react'; import { createPortal } from 'react-dom'; import useEmblaCarousel from 'embla-carousel-react'; import { useGesture } from '@use-gesture/react'; import { motion, useMotionValue, useSpring, animate, useMotionValueEvent } from 'framer-motion'; import { X, FileText, FileArchive, FileSpreadsheet, Image as ImageIcon, Video, Music, File, Download, ZoomIn, ZoomOut, RotateCw, ChevronLeft, ChevronRight, Maximize2, HelpCircle, ArrowLeft, ArrowRight, Plus, Minus, } from 'lucide-react'; import { Button } from '@/components/ui/button'; import { Kbd } from '@/components/ui/kbd'; import { cn, downloadFromFile } from '@/lib/utils'; import { formatBytes } from '@/lib/format'; // ==================== 工具函数 ==================== /** * 根据文件 MIME 类型返回对应的图标 */ export const getFileIcon = (type: string | undefined) => { if (!!type) { if (type.startsWith('image/')) return ; if (type.startsWith('video/')) return