"use client" import React, { useRef, useEffect } from "react"; import "./style/work-flow.css"; import { Skeleton } from "@/components/ui/skeleton"; import { AISuggestionBar } from "@/components/ai-suggestion-bar"; import { EditModal } from "@/components/ui/edit-modal"; import { ErrorBoundary } from "@/components/ui/error-boundary"; 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 } from "lucide-react"; import { motion } from "framer-motion"; import { GlassIconButton } from '@/components/ui/glass-icon-button'; export default function WorkFlow() { const containerRef = useRef(null); const [isEditModalOpen, setIsEditModalOpen] = React.useState(false); const [activeEditTab, setActiveEditTab] = React.useState('1'); // 使用自定义 hooks 管理状态 const { taskObject, taskSketch, taskScenes, taskShotSketch, taskVideos, sketchCount, isLoading, currentStep, currentSketchIndex, isGeneratingSketch, isGeneratingVideo, currentLoadingText, totalSketchCount, roles, music, final, dataLoadError, setCurrentSketchIndex, retryLoadData, isPauseWorkFlow, setIsPauseWorkFlow, } = useWorkflowData(); const { isPlaying, isVideoPlaying, showControls, setShowControls, setIsPlaying, togglePlay, toggleVideoPlay, playTimerRef, } = usePlaybackControls(taskSketch, taskVideos, currentStep); // 跟踪是否已经自动开始播放过,避免重复触发 const hasAutoStartedRef = useRef(false); // 跟踪循环播放的起始索引,用于判断是否完成一轮循环 const loopStartIndexRef = useRef(null); // 调试:监控关键状态变化 useEffect(() => { console.log('工作流状态:', { currentStep, isGeneratingSketch, isGeneratingVideo, isPlaying, taskSketchLength: taskSketch.length, sketchCount, totalSketchCount }); }, [isGeneratingSketch, taskSketch.length, sketchCount, totalSketchCount, currentStep, isPlaying]); // 专门监控isPlaying状态变化 useEffect(() => { console.log('播放状态变化:', isPlaying ? '开始播放' : '停止播放'); }, [isPlaying]); // 检查分镜数据 useEffect(() => { if (taskSketch.length > 0) { console.log('分镜数据:', `${taskSketch.length}个分镜,当前索引:${currentSketchIndex}`); } }, [taskSketch.length, currentSketchIndex]); // 模拟 AI 建议 英文 const mockSuggestions = [ "Refine scene transitions", "Adjust scene composition", "Improve character action design", "Add environmental atmosphere", "Adjust lens language" ]; const handleEditModalOpen = (tab: string) => { setActiveEditTab(tab); setIsEditModalOpen(true); }; const handleSuggestionClick = (suggestion: string) => { console.log('Selected suggestion:', suggestion); }; const handleSubmit = (text: string) => { console.log('Submitted text:', text); }; return (
{dataLoadError ? (

数据加载失败

{dataLoadError}

retryLoadData?.()} whileHover={{ scale: 1.05 }} whileTap={{ scale: 0.95 }} > 重试加载
) : isLoading ? ( ) : (
)}
{/* 暂停/播放按钮 */}
setIsPauseWorkFlow(!isPauseWorkFlow)} />
{/* AI 建议栏 */} setIsEditModalOpen(false)} taskStatus={taskObject?.taskStatus || '1'} taskSketch={taskSketch} sketchVideo={taskVideos} taskScenes={taskScenes} currentSketchIndex={currentSketchIndex} onSketchSelect={setCurrentSketchIndex} roles={roles} music={music} />
) }