重试 剪辑计划

This commit is contained in:
北枳 2025-09-07 04:54:21 +08:00
parent f85187d1de
commit e6f849e0af
4 changed files with 29 additions and 13 deletions

View File

@ -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
NEXT_PUBLIC_ERROR_CONFIG = 0.5

View File

@ -292,8 +292,8 @@ export const getRunningStreamData = async (data: {
};
// 获取 生成剪辑计划 接口
export const getGenerateEditPlan = async (data: GenerateEditPlanRequest): Promise<ApiResponse<GenerateEditPlanResponse>> => {
return post<ApiResponse<GenerateEditPlanResponse>>("/edit-plan/generate-by-project", data);
export const getGenerateEditPlan = async (data: GenerateEditPlanRequest): Promise<ApiResponse<GenerateEditPlanResponseData>> => {
return post<ApiResponse<GenerateEditPlanResponseData>>("/edit-plan/generate-by-project", data);
};
/**

View File

@ -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: () => {

View File

@ -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) {