fix: 修复前端批量处理服务的 JSON-RPC 解析问题
🔧 前端修复: 1. 批量处理服务 JSON-RPC 支持: - 为 batchGenerateVideos 添加 JSON-RPC 2.0 格式解析 - 检测 jsonrpc: '2.0' 并提取 result 字段 - 处理 JSON-RPC 错误响应 - 保持向后兼容直接 JSON 格式 2. 详细的调试日志: - 添加批量请求和响应的详细日志 - 显示原始和解析后的结果 - 区分 JSON-RPC 成功和错误响应 - 便于问题排查和调试 3. Store 状态判断增强: - 添加详细的状态检查日志 - 显示 result.status 的值和类型 - 记录成功和失败的处理路径 - 帮助诊断状态识别问题 4. 错误处理统一: - 批量处理和单个处理使用相同的 JSON-RPC 解析逻辑 - 统一的错误信息格式 - 完整的错误详情记录 🎯 问题解决: - 批量处理服务缺少 JSON-RPC 解析 → 添加完整解析逻辑 ✓ - 前端显示失败状态 → 正确提取 JSON-RPC result ✓ - 调试信息不足 → 添加详细日志 ✓ ✅ 修复效果: - 批量处理正确解析 JSON-RPC 响应 - 前端能够识别批量任务的真实状态 - 详细的调试信息便于问题排查 - 统一的 JSON-RPC 处理逻辑 现在批量处理应该能正确显示成功状态!
This commit is contained in:
parent
45d679c0ea
commit
8a497afa47
|
|
@ -420,10 +420,35 @@ export class AIVideoService {
|
|||
*/
|
||||
static async batchGenerateVideos(request: BatchAIVideoRequest): Promise<any> {
|
||||
try {
|
||||
console.log('Sending batch AI video request:', request)
|
||||
const result = await invoke('batch_generate_ai_videos', { request })
|
||||
return JSON.parse(result as string)
|
||||
console.log('Raw batch result from Tauri:', result)
|
||||
|
||||
const parsedResult = JSON.parse(result as string)
|
||||
console.log('Parsed batch result:', parsedResult)
|
||||
|
||||
// Handle JSON-RPC response format
|
||||
if (parsedResult.jsonrpc === "2.0") {
|
||||
if (parsedResult.result) {
|
||||
// Success response
|
||||
console.log('JSON-RPC batch success result:', parsedResult.result)
|
||||
return parsedResult.result
|
||||
} else if (parsedResult.error) {
|
||||
// Error response
|
||||
console.error('JSON-RPC batch error:', parsedResult.error)
|
||||
throw new Error(parsedResult.error.message || 'JSON-RPC batch error')
|
||||
}
|
||||
}
|
||||
|
||||
// Fallback: direct result format
|
||||
return parsedResult
|
||||
} catch (error) {
|
||||
console.error('Failed to batch generate AI videos:', error)
|
||||
console.error('Batch error details:', {
|
||||
name: error instanceof Error ? error.name : 'Unknown',
|
||||
message: error instanceof Error ? error.message : String(error),
|
||||
stack: error instanceof Error ? error.stack : undefined
|
||||
})
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -173,9 +173,13 @@ export const useAIVideoStore = create<AIVideoState>((set, get) => ({
|
|||
updateJob(jobId, { status: 'processing', progress: 0 })
|
||||
|
||||
const result = await AIVideoService.batchGenerateVideos(request)
|
||||
console.log('Batch processing result in store:', result)
|
||||
console.log('Result status:', result?.status)
|
||||
console.log('Result type:', typeof result?.status)
|
||||
|
||||
// Check if the Python script actually succeeded
|
||||
if (result && result.status === true) {
|
||||
console.log('Batch processing succeeded, updating job to completed')
|
||||
updateJob(jobId, {
|
||||
status: 'completed',
|
||||
progress: 100,
|
||||
|
|
@ -184,6 +188,7 @@ export const useAIVideoStore = create<AIVideoState>((set, get) => ({
|
|||
})
|
||||
} else {
|
||||
// Python script returned failure
|
||||
console.log('Batch processing failed, result:', result)
|
||||
const errorMsg = result?.msg || 'Batch processing failed'
|
||||
updateJob(jobId, {
|
||||
status: 'failed',
|
||||
|
|
|
|||
Loading…
Reference in New Issue