From e6f849e0af3956d838df24fadb919559cbec1066 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8C=97=E6=9E=B3?= <7854742+wang_rumeng@user.noreply.gitee.com> Date: Sun, 7 Sep 2025 04:54:21 +0800 Subject: [PATCH] =?UTF-8?q?=E9=87=8D=E8=AF=95=20=E5=89=AA=E8=BE=91?= =?UTF-8?q?=E8=AE=A1=E5=88=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.development | 2 +- api/video_flow.ts | 4 +-- components/pages/work-flow.tsx | 2 +- .../pages/work-flow/use-workflow-data.tsx | 34 ++++++++++++++----- 4 files changed, 29 insertions(+), 13 deletions(-) diff --git a/.env.development b/.env.development index 7409920..2878ea4 100644 --- a/.env.development +++ b/.env.development @@ -6,4 +6,4 @@ NEXT_PUBLIC_CUT_URL = https://smartcut.movieflow.ai # NEXT_PUBLIC_JAVA_URL = https://test.java.movieflow.ai # NEXT_PUBLIC_BASE_URL = https://test.video.movieflow.ai # 失败率 -NEXT_PUBLIC_ERROR_CONFIG = 0.2 \ No newline at end of file +NEXT_PUBLIC_ERROR_CONFIG = 0.5 \ No newline at end of file diff --git a/api/video_flow.ts b/api/video_flow.ts index e88b38d..a4f2cec 100644 --- a/api/video_flow.ts +++ b/api/video_flow.ts @@ -292,8 +292,8 @@ export const getRunningStreamData = async (data: { }; // 获取 生成剪辑计划 接口 -export const getGenerateEditPlan = async (data: GenerateEditPlanRequest): Promise> => { - return post>("/edit-plan/generate-by-project", data); +export const getGenerateEditPlan = async (data: GenerateEditPlanRequest): Promise> => { + return post>("/edit-plan/generate-by-project", data); }; /** diff --git a/components/pages/work-flow.tsx b/components/pages/work-flow.tsx index edd8e2f..0de4dad 100644 --- a/components/pages/work-flow.tsx +++ b/components/pages/work-flow.tsx @@ -60,7 +60,7 @@ const WorkFlow = React.memo(function WorkFlow() { showEditingNotification({ description: 'Performing intelligent editing...', successDescription: 'Editing successful', - timeoutDescription: 'Editing failed, please try again', + timeoutDescription: 'Editing failed. Please click the edit button to go to the smart editing platform.', timeout: 5 * 60 * 1000, key: editingNotificationKey.current, onFail: () => { diff --git a/components/pages/work-flow/use-workflow-data.tsx b/components/pages/work-flow/use-workflow-data.tsx index 4eb9ea6..99863aa 100644 --- a/components/pages/work-flow/use-workflow-data.tsx +++ b/components/pages/work-flow/use-workflow-data.tsx @@ -76,6 +76,8 @@ export function useWorkflowData({ onEditPlanGenerated }: UseWorkflowDataProps = const [isShowError, setIsShowError] = useState(false); const [isAnalyzing, setIsAnalyzing] = useState(false); const [isGenerateEditPlan, setIsGenerateEditPlan] = useState(false); + const [retryCount, setRetryCount] = useState(0); + const [isLoadingGenerateEditPlan, setIsLoadingGenerateEditPlan] = useState(false); const [state, setState] = useState({ mode: 'automatic' as 'automatic' | 'manual' | 'auto', originalText: '', @@ -137,7 +139,7 @@ export function useWorkflowData({ onEditPlanGenerated }: UseWorkflowDataProps = } }, [taskObject.currentStage]); - const generateEditPlan = useCallback(async () => { + const generateEditPlan = useCallback(async (retryCount: number) => { if (isLoadedRef.current) { return; } @@ -149,7 +151,7 @@ export function useWorkflowData({ onEditPlanGenerated }: UseWorkflowDataProps = // 更新通知内容 showEditingNotification({ key: notificationKey, - description: 'Generating intelligent editing plan...', + 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: 3 * 60 * 1000 @@ -159,8 +161,13 @@ export function useWorkflowData({ onEditPlanGenerated }: UseWorkflowDataProps = setNeedStreamData(false); resolve(true); }); + setIsLoadingGenerateEditPlan(true); try { - await getGenerateEditPlan({ project_id: episodeId }); + const response = await getGenerateEditPlan({ project_id: episodeId }); + if (!response.data.editing_plan) { + throw new Error(response.message); + } + console.error('生成剪辑计划成功'); setIsGenerateEditPlan(true); isLoadedRef.current = 'true'; @@ -170,7 +177,7 @@ export function useWorkflowData({ onEditPlanGenerated }: UseWorkflowDataProps = showEditingNotification({ key: notificationKey, isCompleted: true, - description: 'Generating intelligent editing plan...', + description: `Generating intelligent editing plan... ${retryCount ? 'Retry Time: ' + retryCount : ''}`, successDescription: 'Editing plan generated successfully.', timeout: 3000 }); @@ -180,6 +187,7 @@ export function useWorkflowData({ onEditPlanGenerated }: UseWorkflowDataProps = // 触发回调,通知父组件计划生成完成 onEditPlanGenerated?.(); + setIsLoadingGenerateEditPlan(false); } catch (error) { console.error('生成剪辑计划失败:', error); setNeedStreamData(true); @@ -188,13 +196,14 @@ export function useWorkflowData({ onEditPlanGenerated }: UseWorkflowDataProps = // 显示失败通知3秒 showEditingNotification({ key: notificationKey, - description: '正在生成剪辑计划...', - timeoutDescription: '剪辑计划生成失败,请重试', + description: `Generating intelligent editing plan... ${retryCount ? 'Retry Time: ' + retryCount : ''}`, + timeoutDescription: 'Editing plan generation failed. Retrying later.', timeout: 3000 }); setTimeout(() => { notification.destroy(notificationKey); }, 3000); + setIsLoadingGenerateEditPlan(false); } }, [episodeId, onEditPlanGenerated, notificationKey]); @@ -204,10 +213,17 @@ export function useWorkflowData({ onEditPlanGenerated }: UseWorkflowDataProps = useEffect(() => { // 主动触发剪辑 - if (canGoToCut && (taskObject.currentStage === 'video' || !isGenerateEditPlan)) { - generateEditPlan(); + if (canGoToCut && taskObject.currentStage === 'video') { + generateEditPlan(retryCount); } - }, [canGoToCut, taskObject.currentStage, isGenerateEditPlan]); + }, [canGoToCut, taskObject.currentStage, retryCount]); + + useEffect(() => { + // 加载剪辑计划结束 并且 失败了 重试 + if (!isLoadingGenerateEditPlan && !isGenerateEditPlan) { + setRetryCount(retryCount + 1); + } + }, [isLoadingGenerateEditPlan, isGenerateEditPlan]); useEffect(() => { if (isShowError) {