'use client'; import React, { useState, useEffect, useMemo, useRef } from 'react'; import { motion, AnimatePresence } from 'framer-motion'; import { ScriptModal } from '@/components/ui/script-modal'; import { CheckCircle, Heart, Camera, Film, Scissors, Play, Pause } from 'lucide-react'; import { TaskObject } from '@/api/DTO/movieEdit'; import { GlassIconButton } from '@/components/ui/glass-icon-button'; import { Tooltip } from 'antd'; interface TaskInfoProps { taskObject: TaskObject; currentLoadingText: string; roles: any[]; isPauseWorkFlow: boolean; showGotoCutButton: boolean; onGotoCut?: () => void; setIsPauseWorkFlow: (isPauseWorkFlow: boolean) => void; } const stageIconMap = { 0: { icon: Heart, color: '#8b5cf6' }, 1: { icon: Camera, color: '#06b6d4' }, 2: { icon: Film, color: '#10b981' }, 3: { icon: Scissors, color: '#f59e0b' } } const TAG_COLORS = ['#924eadcc', '#4c90a0', '#3b4a5a', '#957558']; // const TAG_COLORS = ['#6bf5f9', '#92a6fc', '#ac71fd', '#c73dfe']; // 阶段图标组件 const StageIcons = ({ currentStage, isExpanded, isPauseWorkFlow, setIsPauseWorkFlow }: { currentStage: number, isExpanded: boolean, isPauseWorkFlow: boolean, setIsPauseWorkFlow: (isPauseWorkFlow: boolean) => void }) => { // 根据当前阶段重新排序图标 const orderedStages = useMemo(() => { const stages = Object.entries(stageIconMap).map(([stage, data]) => ({ stage: parseInt(stage), ...data })); return stages; }, [currentStage]); return ( setIsPauseWorkFlow(!isPauseWorkFlow)} > {orderedStages.map((stage, index) => { const isCurrentStage = stage.stage === currentStage; const Icon = stage.icon; // 只显示当前阶段或展开状态 if (!isExpanded && !isCurrentStage) return null; return ( 0 ? '8px' : '0px', zIndex: isCurrentStage ? 2 : 1 }} > ); })} ); }; export function TaskInfo({ taskObject, currentLoadingText, roles, isPauseWorkFlow, showGotoCutButton, onGotoCut, setIsPauseWorkFlow }: TaskInfoProps) { const [isScriptModalOpen, setIsScriptModalOpen] = useState(false); const [currentStage, setCurrentStage] = useState(0); const [isStageIconsExpanded, setIsStageIconsExpanded] = useState(false); const timerRef = useRef(null); const stageColor = useMemo(() => { return stageIconMap[currentStage as keyof typeof stageIconMap].color; }, [currentStage]); // 监听 currentLoadingText useEffect(() => { // 清理之前的定时器 if (timerRef.current) { clearTimeout(timerRef.current); timerRef.current = null; } // 统一更新currentStage if (currentLoadingText.includes('initializing') || currentLoadingText.includes('script') || currentLoadingText.includes('character')) { setCurrentStage(0); } else if (currentLoadingText.includes('sketch') && !currentLoadingText.includes('shot sketch')) { setCurrentStage(1); } else if (!currentLoadingText.includes('Post-production') && (currentLoadingText.includes('shot sketch') || currentLoadingText.includes('video'))) { setCurrentStage(2); } else if (currentLoadingText.includes('Post-production')) { setCurrentStage(3); } if (currentLoadingText.includes('Task completed')) { console.log('Closing modal at completion'); setIsScriptModalOpen(false); } if (currentLoadingText.includes('Post-production') || currentLoadingText.includes('status')) { console.log('isScriptModalOpen-Post-production', currentLoadingText, isScriptModalOpen); if (isScriptModalOpen) { setIsScriptModalOpen(false); } else { setIsScriptModalOpen(true); timerRef.current = setTimeout(() => { setIsScriptModalOpen(false); }, 8000); } } if (currentLoadingText.includes('script')) { console.log('isScriptModalOpen-script', currentLoadingText, isScriptModalOpen); setIsScriptModalOpen(true); } if (currentLoadingText.includes('initializing')) { console.log('isScriptModalOpen-initializing', currentLoadingText, isScriptModalOpen); setIsScriptModalOpen(true); } return () => { if (timerRef.current) { clearTimeout(timerRef.current); timerRef.current = null; } } }, [currentLoadingText]); // 使用 useMemo 缓存标签颜色映射 const tagColors = useMemo(() => { if (!taskObject?.tags) return {}; return taskObject.tags.reduce((acc: Record, tag: string) => { acc[tag] = TAG_COLORS[Math.floor(Math.random() * TAG_COLORS.length)]; return acc; }, {}); }, [taskObject?.tags]); // 只在 tags 改变时重新计算 return ( <>
{taskObject?.title ? ( <> {taskObject?.title || 'loading project info...'} ) : 'loading project info...'}
{/* 主题 彩色标签tags */}
{taskObject?.tags?.map((tag: string) => (
{tag}
))}
{ console.log('Modal manually closed'); setIsScriptModalOpen(false); }} currentStage={currentStage} roles={roles} currentLoadingText={currentLoadingText} /> {currentLoadingText === 'Task completed' ? ( <> ) : ( {/* */} {/* 阶段图标 */} setIsStageIconsExpanded(true)} onMouseLeave={() => setIsStageIconsExpanded(false)} > {/* 背景发光效果 */} {isPauseWorkFlow ? 'workflow paused' : currentLoadingText} {/* 主文字 - 颜色填充动画 */} setIsScriptModalOpen(true)} > {currentLoadingText} {/* 动态光点效果 */} {/* */} {/* 文字底部装饰线 */} {/* */} {/* // 跳转剪辑按钮 {showGotoCutButton && ( )} */} )} ); }