diff --git a/.env.development b/.env.development index 5061f56..4a60a63 100644 --- a/.env.development +++ b/.env.development @@ -1,8 +1,17 @@ +<<<<<<< Updated upstream NEXT_PUBLIC_JAVA_URL = https://77.app.java.auth.qikongjian.com # NEXT_PUBLIC_JAVA_URL = http://192.168.120.83:8080 NEXT_PUBLIC_BASE_URL = https://77.smartvideo.py.qikongjian.com NEXT_PUBLIC_CUT_URL = https://smartcut.huiying.video +======= +# NEXT_PUBLIC_JAVA_URL = https://77.app.java.auth.qikongjian.com +# NEXT_PUBLIC_BASE_URL = https://77.smartvideo.py.qikongjian.com +# NEXT_PUBLIC_CUT_URL = https://smartcut.huiying.video +NEXT_PUBLIC_JAVA_URL = https://auth.movieflow.ai +NEXT_PUBLIC_BASE_URL = https://api.video.movieflow.ai +NEXT_PUBLIC_CUT_URL = https://smartcut.movieflow.ai +>>>>>>> Stashed changes # 失败率 NEXT_PUBLIC_ERROR_CONFIG = 0.1 \ No newline at end of file diff --git a/components/pages/work-flow/use-workflow-data.tsx b/components/pages/work-flow/use-workflow-data.tsx index c20934a..03d46b4 100644 --- a/components/pages/work-flow/use-workflow-data.tsx +++ b/components/pages/work-flow/use-workflow-data.tsx @@ -3,6 +3,7 @@ import { useState, useEffect, useCallback, useRef, useMemo } from 'react'; import { useSearchParams } from 'next/navigation'; import { notification } from 'antd'; +import { showEditingNotification } from '@/components/pages/work-flow/editing-notification'; import { detailScriptEpisodeNew, getScriptTitle, getRunningStreamData, pauseMovieProjectPlan, resumeMovieProjectPlan, getGenerateEditPlan, regenerateVideoNew } from '@/api/video_flow'; import { useScriptService } from "@/app/service/Interaction/ScriptService"; import { useUpdateEffect } from '@/app/hooks/useUpdateEffect'; @@ -140,6 +141,66 @@ export function useWorkflowData({ onEditPlanGenerated, editingStatus, onExportFa } }, [taskObject.currentStage]); + const generateEditPlan = useCallback(async (retryCount: number) => { + if (isLoadedRef.current) { + return; + } + // 调用重置方法 + const resetFunc = (window as any)[`resetProgress_${notificationKey}`]; + if (resetFunc) { + resetFunc(); + } + // 更新通知内容 + showEditingNotification({ + key: notificationKey, + description: `Generating intelligent editing plan... ${retryCount ? 'Retry Time: ' + retryCount : ''}`, + successDescription: 'Editing plan generated successfully.', + timeoutDescription: 'Editing plan generation failed. Please refresh and try again.', + timeout: 8 * 60 * 1000 + }); + // 先停止轮询 + await new Promise(resolve => { + setNeedStreamData(false); + resolve(true); + }); + setIsLoadingGenerateEditPlan(true); + try { + const response = await getGenerateEditPlan({ project_id: episodeId }); + if (!response.data.editing_plan) { + throw new Error(response.message); + } + + console.error('生成剪辑计划成功'); + setIsGenerateEditPlan(true); + isLoadedRef.current = 'true'; + setNeedStreamData(true); + + // 销毁生成计划的通知 + notification.destroy(notificationKey); + + // 触发回调,通知父组件计划生成完成 + console.log('📞 calling onEditPlanGenerated callback'); + onEditPlanGenerated?.(); + setIsLoadingGenerateEditPlan(false); + } catch (error) { + console.error('生成剪辑计划失败:', error); + setNeedStreamData(true); + setIsGenerateEditPlan(false); + + // 显示失败通知3秒 + showEditingNotification({ + key: notificationKey, + description: `Generating intelligent editing plan... ${retryCount ? 'Retry Time: ' + retryCount : ''}`, + timeoutDescription: 'Editing plan generation failed. Retrying later.', + timeout: 3000 + }); + setTimeout(() => { + notification.destroy(notificationKey); + setIsLoadingGenerateEditPlan(false); + }, 8000); + } + }, [episodeId, onEditPlanGenerated, notificationKey]); + const openEditPlan = useCallback(async () => { window.open(`${cutUrl}/ai-editor/${episodeId}?token=${token}&user_id=${useid}`, '_target'); }, [episodeId]); @@ -147,7 +208,7 @@ export function useWorkflowData({ onEditPlanGenerated, editingStatus, onExportFa useEffect(() => { // 主动触发剪辑 if (canGoToCut && taskObject.currentStage === 'video' && !isShowError) { - onEditPlanGenerated?.(); + generateEditPlan(retryCount - 1); } }, [canGoToCut, taskObject.currentStage, retryCount, isShowError]); @@ -350,6 +411,17 @@ export function useWorkflowData({ onEditPlanGenerated, editingStatus, onExportFa // 只在第一次检测到视频分析任务时显示通知 if (analyze_video_total_count > 0 && !isAnalyzing && analyze_video_completed_count !== analyze_video_total_count) { setIsAnalyzing(true); + // 如果是第一次显示通知,才调用showEditingNotification + const resetFunc = (window as any)[`resetProgress_${notificationKey}`]; + if (!resetFunc) { + showEditingNotification({ + key: notificationKey, + description: 'Preparing intelligent editing plan...', + successDescription: 'Preparing successful', + timeoutDescription: 'Preparing failed, please try again', + timeout: 3 * 60 * 1000 + }); + } } if (analyze_video_total_count && analyze_video_completed_count === analyze_video_total_count) { @@ -360,6 +432,7 @@ export function useWorkflowData({ onEditPlanGenerated, editingStatus, onExportFa setIsAnalyzing(false); } else { setIsShowError(true); + notification.destroy(notificationKey); setIsAnalyzing(false); } }