'use client'; import React, { useState, useEffect } from 'react'; import { motion, AnimatePresence } from 'framer-motion'; import { X, FileText, Users, Video, Music, Scissors, Settings } from 'lucide-react'; import { cn } from '@/public/lib/utils'; import { ScriptTabContent } from './script-tab-content'; import { VideoTabContent } from './video-tab-content'; import { SettingsTabContent } from './settings-tab-content'; import { CharacterTabContent } from './character-tab-content'; import { MusicTabContent } from './music-tab-content'; interface EditModalProps { isOpen: boolean; onClose: () => void; activeEditTab: string; taskStatus: string; taskSketch: any[]; sketchVideo: any[]; currentSketchIndex: number; onSketchSelect: (index: number) => void; roles?: any[]; music?: any; } const tabs = [ { id: '1', label: 'Script', icon: FileText }, { id: '2', label: 'Character', icon: Users }, { id: '3', label: 'Sketch video', icon: Video }, { id: '4', label: 'Music', icon: Music }, // { id: '5', label: '剪辑', icon: Scissors }, { id: 'settings', label: 'Settings', icon: Settings }, ]; export function EditModal({ isOpen, onClose, activeEditTab, taskStatus, taskSketch, sketchVideo, currentSketchIndex, onSketchSelect, roles = [], music }: EditModalProps) { const [activeTab, setActiveTab] = useState(activeEditTab); const [currentIndex, setCurrentIndex] = useState(currentSketchIndex); // 当 activeEditTab 改变时更新 activeTab useEffect(() => { setActiveTab(activeEditTab); }, [activeEditTab]); useEffect(() => { setCurrentIndex(currentSketchIndex); }, [isOpen]); const isTabDisabled = (tabId: string) => { if (tabId === 'settings') return false; return parseInt(tabId) > parseInt(taskStatus); }; const renderTabContent = () => { switch (activeTab) { case '1': return ( ); case '2': return ( ); case '3': return ( ); case '4': return ( ); case 'settings': return ( { console.log('Setting changed:', key, value); // TODO: 实现设置更新逻辑 }} /> ); default: return (
{tabs.find(tab => tab.id === activeTab)?.label} Content area
); } }; return ( {isOpen && ( <> {/* 背景遮罩 */} {/* 弹窗内容 */}
{/* 标签栏 */}
{tabs.map((tab) => { const Icon = tab.icon; const disabled = isTabDisabled(tab.id); return ( !disabled && setActiveTab(tab.id)} whileHover={disabled ? undefined : { scale: 1.02 }} whileTap={disabled ? undefined : { scale: 0.98 }} > {tab.label} {activeTab === tab.id && ( )} ); })}
{/* 关闭按钮 */}
{/* 内容区域 */}
{renderTabContent()}
{/* 底部操作栏 */}
Reset Save
)}
); }