'use client'; import React, { useState, useEffect } from 'react'; import { motion, AnimatePresence } from 'framer-motion'; import { X, Image, Users, Video, Music, Settings, FileText, Maximize, Minimize } from 'lucide-react'; import { cn } from '@/public/lib/utils'; import ScriptTabContent from './script-tab-content'; import { SceneTabContent } from './scene-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[]; taskScenes: any[]; currentSketchIndex: number; onSketchSelect: (index: number) => void; roles?: any[]; music?: any; } const tabs = [ { id: '0', label: 'Script', icon: FileText }, { id: '1', label: 'Character', icon: Users }, { id: '2', label: 'Scene', icon: Image }, { id: '3', label: 'Shot', 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, taskScenes, currentSketchIndex, onSketchSelect, roles = [], music }: EditModalProps) { const [activeTab, setActiveTab] = useState(activeEditTab); const [currentIndex, setCurrentIndex] = useState(currentSketchIndex); const [currentRoleIndex, setCurrentRoleIndex] = useState(0); useEffect(() => { setCurrentIndex(currentSketchIndex); }, [isOpen]); // 当 activeEditTab 改变时更新 activeTab useEffect(() => { setActiveTab(activeEditTab); }, [activeEditTab]); const isTabDisabled = (tabId: string) => { if (tabId === 'settings') return false; // 换成 如果对应标签下 数据存在 就不禁用 if (tabId === '1') return roles.length === 0; if (tabId === '2') return taskScenes.length === 0; if (tabId === '3') return sketchVideo.length === 0; if (tabId === '4') return false; return false; }; const hanldeChangeSelect = (index: number) => { if (activeTab === '1') { setCurrentRoleIndex(index); } else { setCurrentIndex(index); } } const handleChangeTab = (tabId: string, disabled: boolean) => { if (disabled) return; setActiveTab(tabId); setCurrentIndex(0); } const renderTabContent = () => { switch (activeTab) { case '0': return ( ); 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 ( handleChangeTab(tab.id, disabled)} whileHover={disabled ? undefined : { scale: 1.02 }} whileTap={disabled ? undefined : { scale: 0.98 }} > {tab.label} {activeTab === tab.id && ( )} ); })}
{/* 弹窗操作按钮 */}
{/* 关闭按钮 */}
{/* 内容区域 */}
{renderTabContent()}
{/* 底部操作栏 */}
Reset Save
)}
); }