fix: 修复 Windows 文件路径和状态显示问题
🐛 问题修复: 1. 状态显示错误修复: - 修复 Python 脚本返回失败但界面显示成功的问题 - 在 store 中检查 Python 返回的 status 字段 - 正确处理失败状态并显示错误信息 2. 文件路径验证增强: - 添加前端文件路径格式验证 - 检测并阻止仅文件名的输入 - 要求用户提供完整的文件路径 3. 用户体验改进: - 添加明显的文件路径提示和警告 - 改进错误信息显示,包含详细的失败原因 - 提供具体的解决建议和操作指导 - 优化按钮样式,突出主要操作 4. 错误信息增强: - 显示详细的错误信息和搜索路径 - 添加操作提示和解决方案 - 区分不同类型的错误并提供针对性建议 ✅ 修复效果: - 状态显示准确:失败时正确显示失败状态 ✓ - 路径验证:阻止无效的文件名输入 ✓ - 用户引导:清晰的操作提示和警告 ✓ - 错误处理:详细的错误信息和解决建议 ✓ 现在用户可以清楚地了解操作状态和错误原因,避免文件路径问题!
This commit is contained in:
parent
253d0ccdd1
commit
0c9a050fd5
|
|
@ -130,6 +130,20 @@ const AIVideoGenerator: React.FC<AIVideoGeneratorProps> = ({ 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<AIVideoGeneratorProps> = ({ className = '' }) =
|
|||
<div className="flex items-center space-x-3">
|
||||
<button
|
||||
onClick={handleImageSelect}
|
||||
className="flex items-center px-4 py-2 bg-secondary-100 hover:bg-secondary-200 rounded-lg transition-colors"
|
||||
className="flex items-center px-4 py-2 bg-primary-100 hover:bg-primary-200 text-primary-700 rounded-lg transition-colors"
|
||||
>
|
||||
<Upload size={16} className="mr-2" />
|
||||
选择文件
|
||||
|
|
@ -247,9 +261,12 @@ const AIVideoGenerator: React.FC<AIVideoGeneratorProps> = ({ className = '' }) =
|
|||
type="text"
|
||||
value={selectedImage}
|
||||
onChange={(e) => setSelectedImage(e.target.value)}
|
||||
placeholder="或手动输入图片文件路径"
|
||||
placeholder="或手动输入完整的图片文件路径 (例如: C:\Users\用户名\Pictures\image.jpg)"
|
||||
className="input w-full text-sm"
|
||||
/>
|
||||
<div className="text-xs text-amber-600 bg-amber-50 p-2 rounded border border-amber-200">
|
||||
⚠️ 重要: 请使用"选择文件"按钮或输入完整的文件路径,不要只输入文件名
|
||||
</div>
|
||||
</div>
|
||||
<input
|
||||
ref={fileInputRef}
|
||||
|
|
@ -465,8 +482,17 @@ const AIVideoGenerator: React.FC<AIVideoGeneratorProps> = ({ className = '' }) =
|
|||
)}
|
||||
|
||||
{job.error && (
|
||||
<div className="text-sm text-red-600 bg-red-50 p-2 rounded">
|
||||
{job.error}
|
||||
<div className="text-sm text-red-600 bg-red-50 p-3 rounded border border-red-200">
|
||||
<div className="font-medium mb-1">❌ 生成失败</div>
|
||||
<div className="mb-2">{job.error}</div>
|
||||
{job.result && job.result.msg && job.result.msg !== job.error && (
|
||||
<div className="text-xs text-red-500 mt-1">
|
||||
详细信息: {job.result.msg}
|
||||
</div>
|
||||
)}
|
||||
<div className="text-xs text-red-400 mt-2">
|
||||
💡 提示: 请确保选择了完整的文件路径,而不是仅仅文件名
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
|
|
|
|||
|
|
@ -130,12 +130,25 @@ export const useAIVideoStore = create<AIVideoState>((set, get) => ({
|
|||
|
||||
const result = await AIVideoService.generateVideo(request)
|
||||
|
||||
// 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) {
|
||||
|
|
@ -161,12 +174,25 @@ export const useAIVideoStore = create<AIVideoState>((set, get) => ({
|
|||
|
||||
const result = await AIVideoService.batchGenerateVideos(request)
|
||||
|
||||
// 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) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue