'use client'; import React, { useState, useEffect } from 'react'; import { motion, AnimatePresence } from 'framer-motion'; import { X, Upload, Library, Wand2, Search, FileVideo, Plus, ChevronDown } from 'lucide-react'; import { cn } from '@/public/lib/utils'; import { GenerateVideoModal } from './generate-video-modal'; interface ReplaceVideoModalProps { isOpen: boolean; activeReplaceMethod: string; onClose: () => void; onVideoSelect: (video: any) => void; } export function ReplaceVideoModal({ isOpen, activeReplaceMethod, onClose, onVideoSelect }: ReplaceVideoModalProps) { const [activeMethod, setActiveMethod] = useState(activeReplaceMethod); const [searchQuery, setSearchQuery] = useState(''); const [isGenerateModalOpen, setIsGenerateModalOpen] = React.useState(false); useEffect(() => { setActiveMethod(activeReplaceMethod); }, [activeReplaceMethod]); // 模拟素材库视频数据 const mockLibraryVideos = [ { id: 1, url: 'https://example.com/video1.mp4', title: '烟花绽放', duration: '00:15' }, { id: 2, url: 'https://example.com/video2.mp4', title: '城市夜景', duration: '00:20' }, { id: 3, url: 'https://example.com/video3.mp4', title: '海浪声音', duration: '00:30' }, ]; const handleFileUpload = (event: React.ChangeEvent) => { const file = event.target.files?.[0]; if (file) { // 处理文件上传 console.log('Uploading file:', file); } }; return ( {isOpen && ( <> {/* 背景遮罩 */} {/* 弹窗内容 */}
{/* 标题栏 */}

Video replacement

{/* 主要内容区域 */}
{/* 替换方式选择 */}
setActiveMethod('upload')} whileHover={{ scale: 1.02 }} whileTap={{ scale: 0.98 }} > Upload video setActiveMethod('library')} whileHover={{ scale: 1.02 }} whileTap={{ scale: 0.98 }} > Library setActiveMethod('generate')} whileHover={{ scale: 1.02 }} whileTap={{ scale: 0.98 }} > Generate video
{/* 内容区域 */} {activeMethod === 'upload' && ( )} {activeMethod === 'library' && ( {/* 搜索框 */}
setSearchQuery(e.target.value)} />
{/* 视频列表 */}
{mockLibraryVideos.map((video) => ( onVideoSelect(video)} > ))}
)} {activeMethod === 'generate' && ( setIsGenerateModalOpen(true)} whileHover={{ scale: 1.02 }} whileTap={{ scale: 0.98 }} > Generate new video )}
{/* 底部操作栏 */}
Reset Apply
{/* 生成视频弹窗 */} setIsGenerateModalOpen(false)} onGenerate={(params) => { console.log('Generate video with params:', params); setIsGenerateModalOpen(false); }} /> )}
); }