'use client'; import React, { useState, useEffect } from 'react'; import { motion, AnimatePresence } from 'framer-motion'; import { X, Upload, Library, Wand2, Search, Image, Plus, ChevronDown } from 'lucide-react'; import { cn } from '@/public/lib/utils'; interface ReplaceCharacterModalProps { isOpen: boolean; activeReplaceMethod: string; onClose: () => void; onCharacterSelect: (character: any) => void; } export function ReplaceCharacterModal({ isOpen, activeReplaceMethod, onClose, onCharacterSelect }: ReplaceCharacterModalProps) { const [activeMethod, setActiveMethod] = useState(activeReplaceMethod); const [searchQuery, setSearchQuery] = useState(''); useEffect(() => { setActiveMethod(activeReplaceMethod); }, [activeReplaceMethod]); // 模拟角色库数据 const mockLibraryCharacters = [ { id: 1, avatar: '/assets/3dr_chihiro.png', name: '雪 (YUKI)', style: '动漫风格' }, { id: 2, avatar: '/assets/3dr_mono.png', name: '春 (HARU)', style: '写实风格' }, { id: 3, avatar: '/assets/3dr_chihiro.png', name: '夏 (NATSU)', style: '二次元风格' }, ]; const handleFileUpload = (event: React.ChangeEvent) => { const file = event.target.files?.[0]; if (file) { // 处理文件上传 console.log('Uploading file:', file); } }; return ( {isOpen && ( <> {/* 背景遮罩 */} {/* 弹窗内容 */}
{/* 标题栏 */}

替换角色

{/* 主要内容区域 */}
{/* 替换方式选择 */}
setActiveMethod('upload')} whileHover={{ scale: 1.02 }} whileTap={{ scale: 0.98 }} > 上传角色 setActiveMethod('library')} whileHover={{ scale: 1.02 }} whileTap={{ scale: 0.98 }} > 角色库
{/* 内容区域 */} {activeMethod === 'upload' && ( )} {activeMethod === 'library' && ( {/* 搜索框 */}
setSearchQuery(e.target.value)} />
{/* 角色列表 */}
{mockLibraryCharacters.map((character) => ( onCharacterSelect(character)} > {character.name}

{character.name}

{character.style}

))}
)} {activeMethod === 'generate' && ( console.log('Generate character')} whileHover={{ scale: 1.02 }} whileTap={{ scale: 0.98 }} > 生成新角色 )}
{/* 底部操作栏 */}
重置 应用
)}
); }