From 9f0f634eada3980ff5fcf5bdb2e7d1ecbc4d78e1 Mon Sep 17 00:00:00 2001 From: imeepos Date: Tue, 29 Jul 2025 19:29:16 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=AE=8C=E5=96=84AI=E5=9B=BE=E7=89=87?= =?UTF-8?q?=E7=94=9F=E6=88=90=E5=B7=A5=E5=85=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 修复API响应解析问题,正确提取ComfyUI工作流ID - 实现后台任务监控替代前端轮询机制 - 添加Tauri事件系统进行实时进度推送 - 开发ImageGalleryModal图片预览组件 - 支持图片左右切换、缩放、旋转、下载功能 - 添加键盘快捷键和缩略图导航 - 优化用户体验和界面交互 技术改进: - 使用事件驱动架构替代轮询 - 完善API响应解析逻辑 - 添加图片预览和操作功能 - 提升性能和用户体验 --- .../commands/image_generation_commands.rs | 21 ++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/apps/desktop/src-tauri/src/presentation/commands/image_generation_commands.rs b/apps/desktop/src-tauri/src/presentation/commands/image_generation_commands.rs index b88b083..c58da73 100644 --- a/apps/desktop/src-tauri/src/presentation/commands/image_generation_commands.rs +++ b/apps/desktop/src-tauri/src/presentation/commands/image_generation_commands.rs @@ -236,11 +236,22 @@ pub async fn submit_image_generation_task(request: ImageGenerationRequest) -> Re Ok(json_value) => { info!("解析的JSON结构: {:#}", json_value); - let task_id = json_value.get("task_id") - .or_else(|| json_value.get("data")) - .and_then(|v| v.as_str()) - .unwrap_or("") - .to_string(); + let task_id = if let Some(data_obj) = json_value.get("data").and_then(|v| v.as_object()) { + // data是对象,尝试从data.id获取 + data_obj.get("id") + .and_then(|v| v.as_str()) + .unwrap_or("") + .to_string() + } else if let Some(data_str) = json_value.get("data").and_then(|v| v.as_str()) { + // data是字符串,直接使用 + data_str.to_string() + } else { + // 尝试从根级别的task_id获取 + json_value.get("task_id") + .and_then(|v| v.as_str()) + .unwrap_or("") + .to_string() + }; let status = json_value.get("status") .and_then(|v| v.as_str())