forked from 77media/video-flow
重试 剪辑计划
This commit is contained in:
parent
f85187d1de
commit
e6f849e0af
@ -6,4 +6,4 @@ NEXT_PUBLIC_CUT_URL = https://smartcut.movieflow.ai
|
|||||||
# NEXT_PUBLIC_JAVA_URL = https://test.java.movieflow.ai
|
# NEXT_PUBLIC_JAVA_URL = https://test.java.movieflow.ai
|
||||||
# NEXT_PUBLIC_BASE_URL = https://test.video.movieflow.ai
|
# NEXT_PUBLIC_BASE_URL = https://test.video.movieflow.ai
|
||||||
# 失败率
|
# 失败率
|
||||||
NEXT_PUBLIC_ERROR_CONFIG = 0.2
|
NEXT_PUBLIC_ERROR_CONFIG = 0.5
|
||||||
@ -292,8 +292,8 @@ export const getRunningStreamData = async (data: {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// 获取 生成剪辑计划 接口
|
// 获取 生成剪辑计划 接口
|
||||||
export const getGenerateEditPlan = async (data: GenerateEditPlanRequest): Promise<ApiResponse<GenerateEditPlanResponse>> => {
|
export const getGenerateEditPlan = async (data: GenerateEditPlanRequest): Promise<ApiResponse<GenerateEditPlanResponseData>> => {
|
||||||
return post<ApiResponse<GenerateEditPlanResponse>>("/edit-plan/generate-by-project", data);
|
return post<ApiResponse<GenerateEditPlanResponseData>>("/edit-plan/generate-by-project", data);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -60,7 +60,7 @@ const WorkFlow = React.memo(function WorkFlow() {
|
|||||||
showEditingNotification({
|
showEditingNotification({
|
||||||
description: 'Performing intelligent editing...',
|
description: 'Performing intelligent editing...',
|
||||||
successDescription: 'Editing successful',
|
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,
|
timeout: 5 * 60 * 1000,
|
||||||
key: editingNotificationKey.current,
|
key: editingNotificationKey.current,
|
||||||
onFail: () => {
|
onFail: () => {
|
||||||
|
|||||||
@ -76,6 +76,8 @@ export function useWorkflowData({ onEditPlanGenerated }: UseWorkflowDataProps =
|
|||||||
const [isShowError, setIsShowError] = useState(false);
|
const [isShowError, setIsShowError] = useState(false);
|
||||||
const [isAnalyzing, setIsAnalyzing] = useState(false);
|
const [isAnalyzing, setIsAnalyzing] = useState(false);
|
||||||
const [isGenerateEditPlan, setIsGenerateEditPlan] = useState(false);
|
const [isGenerateEditPlan, setIsGenerateEditPlan] = useState(false);
|
||||||
|
const [retryCount, setRetryCount] = useState(0);
|
||||||
|
const [isLoadingGenerateEditPlan, setIsLoadingGenerateEditPlan] = useState(false);
|
||||||
const [state, setState] = useState({
|
const [state, setState] = useState({
|
||||||
mode: 'automatic' as 'automatic' | 'manual' | 'auto',
|
mode: 'automatic' as 'automatic' | 'manual' | 'auto',
|
||||||
originalText: '',
|
originalText: '',
|
||||||
@ -137,7 +139,7 @@ export function useWorkflowData({ onEditPlanGenerated }: UseWorkflowDataProps =
|
|||||||
}
|
}
|
||||||
}, [taskObject.currentStage]);
|
}, [taskObject.currentStage]);
|
||||||
|
|
||||||
const generateEditPlan = useCallback(async () => {
|
const generateEditPlan = useCallback(async (retryCount: number) => {
|
||||||
if (isLoadedRef.current) {
|
if (isLoadedRef.current) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -149,7 +151,7 @@ export function useWorkflowData({ onEditPlanGenerated }: UseWorkflowDataProps =
|
|||||||
// 更新通知内容
|
// 更新通知内容
|
||||||
showEditingNotification({
|
showEditingNotification({
|
||||||
key: notificationKey,
|
key: notificationKey,
|
||||||
description: 'Generating intelligent editing plan...',
|
description: `Generating intelligent editing plan... ${retryCount ? 'Retry Time: ' + retryCount : ''}`,
|
||||||
successDescription: 'Editing plan generated successfully.',
|
successDescription: 'Editing plan generated successfully.',
|
||||||
timeoutDescription: 'Editing plan generation failed. Please refresh and try again.',
|
timeoutDescription: 'Editing plan generation failed. Please refresh and try again.',
|
||||||
timeout: 3 * 60 * 1000
|
timeout: 3 * 60 * 1000
|
||||||
@ -159,8 +161,13 @@ export function useWorkflowData({ onEditPlanGenerated }: UseWorkflowDataProps =
|
|||||||
setNeedStreamData(false);
|
setNeedStreamData(false);
|
||||||
resolve(true);
|
resolve(true);
|
||||||
});
|
});
|
||||||
|
setIsLoadingGenerateEditPlan(true);
|
||||||
try {
|
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('生成剪辑计划成功');
|
console.error('生成剪辑计划成功');
|
||||||
setIsGenerateEditPlan(true);
|
setIsGenerateEditPlan(true);
|
||||||
isLoadedRef.current = 'true';
|
isLoadedRef.current = 'true';
|
||||||
@ -170,7 +177,7 @@ export function useWorkflowData({ onEditPlanGenerated }: UseWorkflowDataProps =
|
|||||||
showEditingNotification({
|
showEditingNotification({
|
||||||
key: notificationKey,
|
key: notificationKey,
|
||||||
isCompleted: true,
|
isCompleted: true,
|
||||||
description: 'Generating intelligent editing plan...',
|
description: `Generating intelligent editing plan... ${retryCount ? 'Retry Time: ' + retryCount : ''}`,
|
||||||
successDescription: 'Editing plan generated successfully.',
|
successDescription: 'Editing plan generated successfully.',
|
||||||
timeout: 3000
|
timeout: 3000
|
||||||
});
|
});
|
||||||
@ -180,6 +187,7 @@ export function useWorkflowData({ onEditPlanGenerated }: UseWorkflowDataProps =
|
|||||||
|
|
||||||
// 触发回调,通知父组件计划生成完成
|
// 触发回调,通知父组件计划生成完成
|
||||||
onEditPlanGenerated?.();
|
onEditPlanGenerated?.();
|
||||||
|
setIsLoadingGenerateEditPlan(false);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('生成剪辑计划失败:', error);
|
console.error('生成剪辑计划失败:', error);
|
||||||
setNeedStreamData(true);
|
setNeedStreamData(true);
|
||||||
@ -188,13 +196,14 @@ export function useWorkflowData({ onEditPlanGenerated }: UseWorkflowDataProps =
|
|||||||
// 显示失败通知3秒
|
// 显示失败通知3秒
|
||||||
showEditingNotification({
|
showEditingNotification({
|
||||||
key: notificationKey,
|
key: notificationKey,
|
||||||
description: '正在生成剪辑计划...',
|
description: `Generating intelligent editing plan... ${retryCount ? 'Retry Time: ' + retryCount : ''}`,
|
||||||
timeoutDescription: '剪辑计划生成失败,请重试',
|
timeoutDescription: 'Editing plan generation failed. Retrying later.',
|
||||||
timeout: 3000
|
timeout: 3000
|
||||||
});
|
});
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
notification.destroy(notificationKey);
|
notification.destroy(notificationKey);
|
||||||
}, 3000);
|
}, 3000);
|
||||||
|
setIsLoadingGenerateEditPlan(false);
|
||||||
}
|
}
|
||||||
}, [episodeId, onEditPlanGenerated, notificationKey]);
|
}, [episodeId, onEditPlanGenerated, notificationKey]);
|
||||||
|
|
||||||
@ -204,10 +213,17 @@ export function useWorkflowData({ onEditPlanGenerated }: UseWorkflowDataProps =
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
// 主动触发剪辑
|
// 主动触发剪辑
|
||||||
if (canGoToCut && (taskObject.currentStage === 'video' || !isGenerateEditPlan)) {
|
if (canGoToCut && taskObject.currentStage === 'video') {
|
||||||
generateEditPlan();
|
generateEditPlan(retryCount);
|
||||||
}
|
}
|
||||||
}, [canGoToCut, taskObject.currentStage, isGenerateEditPlan]);
|
}, [canGoToCut, taskObject.currentStage, retryCount]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
// 加载剪辑计划结束 并且 失败了 重试
|
||||||
|
if (!isLoadingGenerateEditPlan && !isGenerateEditPlan) {
|
||||||
|
setRetryCount(retryCount + 1);
|
||||||
|
}
|
||||||
|
}, [isLoadingGenerateEditPlan, isGenerateEditPlan]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (isShowError) {
|
if (isShowError) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user