'use client'; import React, { useState, useEffect, SetStateAction } from 'react'; import { motion, AnimatePresence } from 'framer-motion'; import { X, Image, Users, Video, Music, Settings, FileText, Undo2, TriangleAlert } from 'lucide-react'; import { cn } from '@/public/lib/utils'; import { ScriptTabContent } from './script-tab-content'; import { SceneTabContent } from './scene-tab-content'; import { ShotTabContent } from './shot-tab-content'; import { SettingsTabContent } from './settings-tab-content'; import { CharacterTabContent } from './character-tab-content'; import { MusicTabContent } from './music-tab-content'; import FloatingGlassPanel from './FloatingGlassPanel'; 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; setIsPauseWorkFlow: (isPauseWorkFlow: boolean) => void; setAnyAttribute: any; isPauseWorkFlow: boolean; scriptData: any[] | null; applyScript: any; fallbackToStep: any; } const tabs = [ { id: '0', label: 'Script', icon: FileText }, { id: '1', label: 'Character', icon: Users }, { id: '2', label: 'Scene', icon: Image }, { id: '3', label: '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, taskScenes, currentSketchIndex, onSketchSelect, roles = [], music, setIsPauseWorkFlow, setAnyAttribute, isPauseWorkFlow, scriptData, applyScript, fallbackToStep }: EditModalProps) { const [activeTab, setActiveTab] = useState(activeEditTab); const [currentIndex, setCurrentIndex] = useState(currentSketchIndex); const [currentRoleIndex, setCurrentRoleIndex] = useState(0); const [isRemindFallbackOpen, setIsRemindFallbackOpen] = useState(false); 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 handleSave = () => { console.log('handleSave'); setIsRemindFallbackOpen(true); } const handleConfirmGotoFallback = () => { console.log('handleConfirmGotoFallback'); if (activeTab === '0') { fallbackToStep('0'); // 应用剧本 applyScript(); } else { fallbackToStep('1'); } } const handleCloseRemindFallbackPanel = () => { setIsRemindFallbackOpen(false); } 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 {handleSave()}} > Save
{/* 提醒用户 点击保存 工作流将回退 并重新执行工作流 */}

The task will be regenerated and edited. Do you want to continue?

)}
); }