forked from 77media/video-flow
取多多余的进度条提示信息,所有提示信息走work-flow页面export-service只作为公用方法不做弹窗提醒
This commit is contained in:
parent
d826b3c57e
commit
8836138283
@ -14,7 +14,7 @@ import { SaveEditUseCase } from "@/app/service/usecase/SaveEditUseCase";
|
||||
import { useSearchParams } from "next/navigation";
|
||||
import SmartChatBox from "@/components/SmartChatBox/SmartChatBox";
|
||||
import { Drawer, Tooltip, notification } from 'antd';
|
||||
import { showEditingNotification } from "@/components/pages/work-flow/editing-notification";
|
||||
// import { showEditingNotification } from "@/components/pages/work-flow/editing-notification";
|
||||
// import { AIEditingIframeButton } from './work-flow/ai-editing-iframe';
|
||||
import { exportVideoWithRetry } from '@/utils/export-service';
|
||||
|
||||
@ -76,7 +76,8 @@ const WorkFlow = React.memo(function WorkFlow() {
|
||||
console.log('📊 导出进度更新:', progressData);
|
||||
setExportProgress(progressData);
|
||||
|
||||
// 根据状态显示不同的通知
|
||||
// 根据状态显示不同的通知 - 已注释
|
||||
/*
|
||||
if (progressData.status === 'processing') {
|
||||
notification.info({
|
||||
message: '导出进度',
|
||||
@ -102,6 +103,7 @@ const WorkFlow = React.memo(function WorkFlow() {
|
||||
key: 'export-progress'
|
||||
});
|
||||
}
|
||||
*/
|
||||
}, []);
|
||||
// 处理编辑计划生成完成的回调
|
||||
const handleEditPlanGenerated = useCallback(() => {
|
||||
@ -125,6 +127,8 @@ const WorkFlow = React.memo(function WorkFlow() {
|
||||
setTimeout(() => {
|
||||
handleTestExportRef.current?.();
|
||||
}, 0);
|
||||
// 编辑通知已全部注释
|
||||
/*
|
||||
editingNotificationKey.current = `editing-${Date.now()}`;
|
||||
showEditingNotification({
|
||||
description: 'Performing intelligent editing...',
|
||||
@ -172,6 +176,7 @@ const WorkFlow = React.memo(function WorkFlow() {
|
||||
}, 200);
|
||||
}
|
||||
});
|
||||
*/
|
||||
}, [episodeId]); // handleTestExport 在内部调用,无需作为依赖
|
||||
|
||||
/** 处理导出失败 */
|
||||
@ -221,7 +226,8 @@ const WorkFlow = React.memo(function WorkFlow() {
|
||||
console.log('changedIndex_work-flow', currentSketchIndex, taskObject);
|
||||
}, [currentSketchIndex, taskObject]);
|
||||
|
||||
// 监听粗剪是否完成,如果完成 更新 showEditingNotification 的状态 为完成,延时 3s 并关闭
|
||||
// 监听粗剪是否完成 - 已注释,不显示右上角成功通知
|
||||
/*
|
||||
useEffect(() => {
|
||||
console.log('🎬 final video useEffect triggered:', {
|
||||
finalUrl: taskObject.final.url,
|
||||
@ -255,6 +261,7 @@ const WorkFlow = React.memo(function WorkFlow() {
|
||||
});
|
||||
}
|
||||
}, [taskObject.final, isHandleEdit, episodeId]);
|
||||
*/
|
||||
|
||||
const handleEditModalOpen = useCallback((tab: string) => {
|
||||
setActiveEditTab(tab);
|
||||
@ -435,7 +442,8 @@ const WorkFlow = React.memo(function WorkFlow() {
|
||||
}
|
||||
*/}
|
||||
|
||||
{/* 导出进度显示 */}
|
||||
{/* 导出进度显示 - 已注释 */}
|
||||
{/*
|
||||
{exportProgress && exportProgress.status === 'processing' && (
|
||||
<div className="fixed right-[1rem] bottom-[20rem] z-[49]">
|
||||
<div className="backdrop-blur-lg bg-black/30 border border-white/20 rounded-lg p-4 max-w-xs">
|
||||
@ -455,6 +463,7 @@ const WorkFlow = React.memo(function WorkFlow() {
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
*/}
|
||||
|
||||
{/* 测试导出接口按钮 - 隐藏显示(仍可通过逻辑调用) */}
|
||||
<div
|
||||
|
||||
@ -115,8 +115,8 @@ export class VideoExportService {
|
||||
this.config = {
|
||||
maxRetries: config.maxRetries || 3,
|
||||
pollInterval: config.pollInterval || 5000, // 5秒轮询
|
||||
apiBaseUrl: process.env.NEXT_PUBLIC_CUT_URL || 'https://smartcut.api.movieflow.ai',
|
||||
//apiBaseUrl: config.apiBaseUrl || 'https://smartcut.api.movieflow.ai'
|
||||
apiBaseUrl: 'https://smartcut.api.movieflow.ai',
|
||||
//apiBaseUrl: process.env.NEXT_PUBLIC_CUT_URL || || 'https://smartcut.api.movieflow.ai'
|
||||
};
|
||||
}
|
||||
|
||||
@ -356,6 +356,7 @@ export class VideoExportService {
|
||||
});
|
||||
|
||||
console.log('📡 导出接口响应状态:', response.status, response.statusText);
|
||||
console.log('📋 响应头信息:', Object.fromEntries(response.headers.entries()));
|
||||
|
||||
if (!response.ok) {
|
||||
const errorText = await response.text();
|
||||
@ -363,6 +364,8 @@ export class VideoExportService {
|
||||
throw new Error(`HTTP error! status: ${response.status}, message: ${errorText}`);
|
||||
}
|
||||
|
||||
console.log('✅ 导出接口调用成功,开始处理SSE流...');
|
||||
|
||||
// 处理SSE流式响应
|
||||
console.log('📺 开始处理流式响应...');
|
||||
const reader = response.body?.getReader();
|
||||
@ -410,12 +413,14 @@ export class VideoExportService {
|
||||
break;
|
||||
|
||||
case 'complete':
|
||||
console.log('🎉 导出完成!', eventData);
|
||||
console.log('🎉 导出完成!完整事件数据:', JSON.stringify(eventData, null, 2));
|
||||
finalResult = eventData;
|
||||
// 确保最终结果包含任务ID
|
||||
if (detectedTaskId && !finalResult.export_id && !finalResult.task_id) {
|
||||
finalResult.export_id = detectedTaskId;
|
||||
console.log('📋 添加检测到的任务ID到完成结果:', detectedTaskId);
|
||||
}
|
||||
console.log('✅ 最终SSE结果:', JSON.stringify(finalResult, null, 2));
|
||||
// 导出完成,退出循环
|
||||
return finalResult;
|
||||
|
||||
@ -468,13 +473,14 @@ export class VideoExportService {
|
||||
}
|
||||
|
||||
const progressData = await response.json();
|
||||
console.log('📈 进度数据:', progressData);
|
||||
console.log('📈 进度查询响应状态:', response.status, response.statusText);
|
||||
console.log('📊 完整进度数据:', JSON.stringify(progressData, null, 2));
|
||||
|
||||
// 根据API返回的数据结构处理
|
||||
const { status, progress } = progressData;
|
||||
|
||||
if (status === 'completed') {
|
||||
console.log('🎉 导出任务完成!', progress);
|
||||
console.log('🎉 导出任务完成!progress数据:', JSON.stringify(progress, null, 2));
|
||||
|
||||
// 触发完成状态回调
|
||||
if (progressCallback) {
|
||||
@ -487,7 +493,7 @@ export class VideoExportService {
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
const completedResult = {
|
||||
task_id: taskId,
|
||||
status: status,
|
||||
video_url: progress?.video_url,
|
||||
@ -497,6 +503,9 @@ export class VideoExportService {
|
||||
watermark_status: progress?.watermark_status,
|
||||
upload_time: progress?.upload_time
|
||||
};
|
||||
|
||||
console.log('✅ 轮询返回的完成结果:', JSON.stringify(completedResult, null, 2));
|
||||
return completedResult;
|
||||
} else if (status === 'failed') {
|
||||
console.log('❌ 导出任务失败,需要重新调用 api/export/stream');
|
||||
|
||||
@ -600,13 +609,15 @@ export class VideoExportService {
|
||||
if (!taskId) {
|
||||
console.log('⚠️ SSE结果中未找到任务ID,无法进行进度轮询');
|
||||
|
||||
// 显示警告通知
|
||||
// 显示警告通知 - 已注释
|
||||
/*
|
||||
notification.warning({
|
||||
message: `第${currentAttempt}次导出接口调用成功`,
|
||||
description: 'SSE流中未找到任务ID,无法进行进度轮询。请检查API返回数据结构。',
|
||||
placement: 'topRight',
|
||||
duration: 8
|
||||
});
|
||||
*/
|
||||
|
||||
// 如果SSE中直接有完整结果,直接处理
|
||||
if (result?.download_url || result?.video_url) {
|
||||
@ -614,14 +625,14 @@ export class VideoExportService {
|
||||
console.log('📥 直接从SSE结果下载视频:', downloadUrl);
|
||||
await downloadVideo(downloadUrl);
|
||||
|
||||
notification.success({
|
||||
message: '视频下载完成!',
|
||||
description: result?.file_size
|
||||
? `文件大小: ${(result.file_size / 1024 / 1024).toFixed(2)}MB`
|
||||
: '视频已成功下载到本地',
|
||||
placement: 'topRight',
|
||||
duration: 8
|
||||
});
|
||||
// notification.success({
|
||||
// message: '视频下载完成!',
|
||||
// description: result?.file_size
|
||||
// ? `文件大小: ${(result.file_size / 1024 / 1024).toFixed(2)}MB`
|
||||
// : '视频已成功下载到本地',
|
||||
// placement: 'topRight',
|
||||
// duration: 8
|
||||
// });
|
||||
}
|
||||
|
||||
return result;
|
||||
@ -635,18 +646,26 @@ export class VideoExportService {
|
||||
|
||||
// 导出成功
|
||||
console.log('🎉 导出成功完成!');
|
||||
console.log('📋 轮询最终结果:', JSON.stringify(finalExportResult, null, 2));
|
||||
|
||||
// 显示最终成功通知
|
||||
// 显示最终成功通知 - 已注释
|
||||
/*
|
||||
notification.success({
|
||||
message: `导出成功!(第${currentAttempt}次尝试)`,
|
||||
description: `文件大小: ${(finalExportResult.file_size! / 1024 / 1024).toFixed(2)}MB,正在下载到本地...`,
|
||||
placement: 'topRight',
|
||||
duration: 8
|
||||
});
|
||||
*/
|
||||
|
||||
// 自动下载视频
|
||||
if (finalExportResult.video_url) {
|
||||
console.log('📥 开始下载视频:', finalExportResult.video_url);
|
||||
console.log('📋 视频文件信息:', {
|
||||
url: finalExportResult.video_url,
|
||||
file_size: finalExportResult.file_size,
|
||||
quality_mode: finalExportResult.quality_mode
|
||||
});
|
||||
await downloadVideo(finalExportResult.video_url);
|
||||
console.log('✅ 视频下载完成');
|
||||
}
|
||||
@ -669,12 +688,12 @@ export class VideoExportService {
|
||||
if (currentAttempt < this.config.maxRetries) {
|
||||
console.log(`🔄 准备第${currentAttempt + 1}次重试(重新调用 api/export/stream)...`);
|
||||
|
||||
notification.warning({
|
||||
message: `第${currentAttempt}次导出失败`,
|
||||
description: `导出状态: failed。正在准备第${currentAttempt + 1}次重试...`,
|
||||
placement: 'topRight',
|
||||
duration: 5
|
||||
});
|
||||
// notification.warning({
|
||||
// message: `第${currentAttempt}次导出失败`,
|
||||
// description: `导出状态: failed。正在准备第${currentAttempt + 1}次重试...`,
|
||||
// placement: 'topRight',
|
||||
// duration: 5
|
||||
// });
|
||||
|
||||
currentAttempt++;
|
||||
continue; // 继续重试循环,重新调用 api/export/stream
|
||||
@ -687,12 +706,12 @@ export class VideoExportService {
|
||||
if (currentAttempt < this.config.maxRetries) {
|
||||
console.log(`🔄 轮询失败,准备第${currentAttempt + 1}次重试...`);
|
||||
|
||||
notification.warning({
|
||||
message: `第${currentAttempt}次轮询失败`,
|
||||
description: `${pollError instanceof Error ? pollError.message : '未知错误'}。正在准备第${currentAttempt + 1}次重试...`,
|
||||
placement: 'topRight',
|
||||
duration: 5
|
||||
});
|
||||
// notification.warning({
|
||||
// message: `第${currentAttempt}次轮询失败`,
|
||||
// description: `${pollError instanceof Error ? pollError.message : '未知错误'}。正在准备第${currentAttempt + 1}次重试...`,
|
||||
// placement: 'topRight',
|
||||
// duration: 5
|
||||
// });
|
||||
|
||||
currentAttempt++;
|
||||
continue; // 继续重试循环
|
||||
@ -700,12 +719,12 @@ export class VideoExportService {
|
||||
// 已达到最大重试次数,回退到SSE结果
|
||||
console.log('❌ 已达到最大重试次数,回退到SSE结果');
|
||||
|
||||
notification.error({
|
||||
message: '轮询重试失败',
|
||||
description: `已重试${this.config.maxRetries}次仍然失败。${pollError instanceof Error ? pollError.message : '未知错误'}`,
|
||||
placement: 'topRight',
|
||||
duration: 10
|
||||
});
|
||||
// notification.error({
|
||||
// message: '轮询重试失败',
|
||||
// description: `已重试${this.config.maxRetries}次仍然失败。${pollError instanceof Error ? pollError.message : '未知错误'}`,
|
||||
// placement: 'topRight',
|
||||
// duration: 10
|
||||
// });
|
||||
|
||||
// 回退到SSE结果
|
||||
if (result?.download_url || result?.video_url) {
|
||||
@ -729,12 +748,12 @@ export class VideoExportService {
|
||||
if (currentAttempt < this.config.maxRetries) {
|
||||
console.log(`🔄 第${currentAttempt}次尝试失败,准备第${currentAttempt + 1}次重试...`);
|
||||
|
||||
notification.warning({
|
||||
message: `第${currentAttempt}次导出尝试失败`,
|
||||
description: `${attemptError instanceof Error ? attemptError.message : '未知错误'}。正在准备第${currentAttempt + 1}次重试...`,
|
||||
placement: 'topRight',
|
||||
duration: 5
|
||||
});
|
||||
// notification.warning({
|
||||
// message: `第${currentAttempt}次导出尝试失败`,
|
||||
// description: `${attemptError instanceof Error ? attemptError.message : '未知错误'}。正在准备第${currentAttempt + 1}次重试...`,
|
||||
// placement: 'topRight',
|
||||
// duration: 5
|
||||
// });
|
||||
|
||||
currentAttempt++;
|
||||
continue; // 继续重试循环
|
||||
@ -754,13 +773,15 @@ export class VideoExportService {
|
||||
// 清除缓存的请求数据
|
||||
this.cachedExportRequest = null;
|
||||
|
||||
// 显示最终错误通知
|
||||
// 显示最终错误通知 - 已注释
|
||||
/*
|
||||
notification.error({
|
||||
message: '视频导出失败',
|
||||
description: `经过${this.config.maxRetries}次尝试后仍然失败:${error instanceof Error ? error.message : '未知错误'}`,
|
||||
placement: 'topRight',
|
||||
duration: 10
|
||||
});
|
||||
*/
|
||||
|
||||
throw error;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user