From 0c9a050fd582b277cd3fbea272a32f87b2918bee Mon Sep 17 00:00:00 2001 From: root Date: Thu, 10 Jul 2025 11:53:30 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=20Windows=20=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E8=B7=AF=E5=BE=84=E5=92=8C=E7=8A=B6=E6=80=81=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 🐛 问题修复: 1. 状态显示错误修复: - 修复 Python 脚本返回失败但界面显示成功的问题 - 在 store 中检查 Python 返回的 status 字段 - 正确处理失败状态并显示错误信息 2. 文件路径验证增强: - 添加前端文件路径格式验证 - 检测并阻止仅文件名的输入 - 要求用户提供完整的文件路径 3. 用户体验改进: - 添加明显的文件路径提示和警告 - 改进错误信息显示,包含详细的失败原因 - 提供具体的解决建议和操作指导 - 优化按钮样式,突出主要操作 4. 错误信息增强: - 显示详细的错误信息和搜索路径 - 添加操作提示和解决方案 - 区分不同类型的错误并提供针对性建议 ✅ 修复效果: - 状态显示准确:失败时正确显示失败状态 ✓ - 路径验证:阻止无效的文件名输入 ✓ - 用户引导:清晰的操作提示和警告 ✓ - 错误处理:详细的错误信息和解决建议 ✓ 现在用户可以清楚地了解操作状态和错误原因,避免文件路径问题! --- src/components/AIVideoGenerator.tsx | 34 +++++++++++++++--- src/stores/useAIVideoStore.ts | 54 +++++++++++++++++++++-------- 2 files changed, 70 insertions(+), 18 deletions(-) diff --git a/src/components/AIVideoGenerator.tsx b/src/components/AIVideoGenerator.tsx index 04c33f6..c70e60a 100644 --- a/src/components/AIVideoGenerator.tsx +++ b/src/components/AIVideoGenerator.tsx @@ -130,6 +130,20 @@ const AIVideoGenerator: React.FC = ({ className = '' }) = return } + // Validate file path + if (!selectedImage.includes('\\') && !selectedImage.includes('/')) { + alert('请选择完整的文件路径,而不是仅仅文件名。\n\n请点击"选择文件"按钮来选择图片文件。') + return + } + + console.log('Generating video with:', { + image_path: selectedImage, + prompt: customPrompt, + duration, + model_type: modelType, + output_path: outputFolder + }) + await generateSingleVideo({ image_path: selectedImage, prompt: customPrompt, @@ -234,7 +248,7 @@ const AIVideoGenerator: React.FC = ({ className = '' }) =
= ({ className = '' }) = )} {job.error && ( -
- {job.error} +
+
❌ 生成失败
+
{job.error}
+ {job.result && job.result.msg && job.result.msg !== job.error && ( +
+ 详细信息: {job.result.msg} +
+ )} +
+ 💡 提示: 请确保选择了完整的文件路径,而不是仅仅文件名 +
)} diff --git a/src/stores/useAIVideoStore.ts b/src/stores/useAIVideoStore.ts index a601a1f..89dc50f 100644 --- a/src/stores/useAIVideoStore.ts +++ b/src/stores/useAIVideoStore.ts @@ -129,13 +129,26 @@ export const useAIVideoStore = create((set, get) => ({ updateJob(jobId, { status: 'processing', progress: 0 }) const result = await AIVideoService.generateVideo(request) - - updateJob(jobId, { - status: 'completed', - progress: 100, - result, - endTime: Date.now() - }) + + // Check if the Python script actually succeeded + if (result && result.status === true) { + updateJob(jobId, { + status: 'completed', + progress: 100, + result, + endTime: Date.now() + }) + } else { + // Python script returned failure + const errorMsg = result?.msg || 'Python script execution failed' + updateJob(jobId, { + status: 'failed', + error: errorMsg, + result, + endTime: Date.now() + }) + throw new Error(errorMsg) + } return jobId } catch (error) { @@ -160,13 +173,26 @@ export const useAIVideoStore = create((set, get) => ({ updateJob(jobId, { status: 'processing', progress: 0 }) const result = await AIVideoService.batchGenerateVideos(request) - - updateJob(jobId, { - status: 'completed', - progress: 100, - result, - endTime: Date.now() - }) + + // Check if the Python script actually succeeded + if (result && result.status === true) { + updateJob(jobId, { + status: 'completed', + progress: 100, + result, + endTime: Date.now() + }) + } else { + // Python script returned failure + const errorMsg = result?.msg || 'Batch processing failed' + updateJob(jobId, { + status: 'failed', + error: errorMsg, + result, + endTime: Date.now() + }) + throw new Error(errorMsg) + } return jobId } catch (error) {