"use client" import React, { useRef, useEffect, useCallback } from "react"; import "./style/work-flow.css"; import { Skeleton } from "@/components/ui/skeleton"; import { EditModal } from "@/components/ui/edit-modal"; import { TaskInfo } from "./work-flow/task-info"; import { MediaViewer } from "./work-flow/media-viewer"; import { ThumbnailGrid } from "./work-flow/thumbnail-grid"; import { useWorkflowData } from "./work-flow/use-workflow-data"; import { usePlaybackControls } from "./work-flow/use-playback-controls"; import { AlertCircle, RefreshCw, Pause, Play, ChevronLast, ChevronsLeft, Bot, BriefcaseBusiness, Scissors } from "lucide-react"; import { motion } from "framer-motion"; import { GlassIconButton } from '@/components/ui/glass-icon-button'; import { SaveEditUseCase } from "@/app/service/usecase/SaveEditUseCase"; import { useSearchParams } from "next/navigation"; import SmartChatBox from "@/components/SmartChatBox/SmartChatBox"; import { Drawer, Tooltip } from 'antd'; const WorkFlow = React.memo(function WorkFlow() { useEffect(() => { console.log("init-WorkFlow"); return () => console.log("unmount-WorkFlow"); }, []); const containerRef = useRef(null); const [isEditModalOpen, setIsEditModalOpen] = React.useState(false); const [activeEditTab, setActiveEditTab] = React.useState('1'); const [isSmartChatBoxOpen, setIsSmartChatBoxOpen] = React.useState(true); const [previewVideoUrl, setPreviewVideoUrl] = React.useState(null); const [previewVideoId, setPreviewVideoId] = React.useState(null); const [isFocusChatInput, setIsFocusChatInput] = React.useState(false); const [isHovered, setIsHovered] = React.useState(false); const searchParams = useSearchParams(); const episodeId = searchParams.get('episodeId') || ''; const userId = JSON.parse(localStorage.getItem("currentUser") || '{}').id || NaN; SaveEditUseCase.setProjectId(episodeId); // 使用自定义 hooks 管理状态 const { taskObject, scriptData, isLoading, currentSketchIndex, currentLoadingText, dataLoadError, setCurrentSketchIndex, retryLoadData, isPauseWorkFlow, mode, setIsPauseWorkFlow, setAnyAttribute, applyScript, fallbackToStep, originalText, showGotoCutButton, generateEditPlan, handleRetryVideo } = useWorkflowData(); const { isVideoPlaying, toggleVideoPlay, } = usePlaybackControls(taskObject.videos.data, taskObject.currentStage); useEffect(() => { console.log('changedIndex_work-flow', currentSketchIndex, taskObject); }, [currentSketchIndex]); // 模拟 AI 建议 英文 const mockSuggestions = [ "Refine scene transitions", "Adjust scene composition", "Improve character action design", "Add environmental atmosphere", "Adjust lens language" ]; const handleEditModalOpen = useCallback((tab: string) => { setActiveEditTab(tab); setIsEditModalOpen(true); }, []); return (
{isLoading ? ( ) : (
setIsSmartChatBoxOpen(true)} setVideoPreview={(url, id) => { setPreviewVideoUrl(url); setPreviewVideoId(id); }} showGotoCutButton={showGotoCutButton} onGotoCut={generateEditPlan} isSmartChatBoxOpen={isSmartChatBoxOpen} onRetryVideo={(video_id) => handleRetryVideo(video_id)} />
)}
{taskObject.currentStage !== 'final_video' && taskObject.currentStage !== 'script' && (
)}
{/* 智能对话按钮 */}
setIsSmartChatBoxOpen(true)} className="backdrop-blur-lg" />
{/* 智能对话弹窗 */} setIsSmartChatBoxOpen(false)} > { setPreviewVideoUrl(null); setPreviewVideoId(null); }} /> { SaveEditUseCase.clearData(); setIsEditModalOpen(false) }} taskObject={taskObject} currentSketchIndex={currentSketchIndex} roles={taskObject.roles.data} setIsPauseWorkFlow={setIsPauseWorkFlow} isPauseWorkFlow={isPauseWorkFlow} fallbackToStep={fallbackToStep} originalText={originalText} />
) }); export default WorkFlow;