diff --git a/apps/desktop/src-tauri/src/business/services/comfyui_service.rs b/apps/desktop/src-tauri/src/business/services/comfyui_service.rs index 4dc46b5..f0d1313 100644 --- a/apps/desktop/src-tauri/src/business/services/comfyui_service.rs +++ b/apps/desktop/src-tauri/src/business/services/comfyui_service.rs @@ -308,11 +308,11 @@ impl ComfyUIService { if let Some(Value::String(title)) = meta.get("title") { if title.contains("BOWONG-INPUT-") { should_replace = true; - if title.contains("模特") || title.contains("MODEL") || title.contains("AVATAR") { + if title.contains("模特") && !title.contains("描述") { replacement_type = "model"; } else if title.contains("穿搭") || title.contains("商品") || title.contains("PRODUCT") || title.contains("CLOTH") { replacement_type = "product"; - } else if title.contains("提示") || title.contains("PROMPT") || title.contains("TEXT") { + } else if title.contains("提示") || title.contains("PROMPT") || title.contains("TEXT") || title.contains("描述") { replacement_type = "prompt"; } else if title.contains("负面") || title.contains("NEGATIVE") { replacement_type = "negative"; @@ -364,17 +364,48 @@ impl ComfyUIService { }); } "prompt" => { + // 根据节点类型决定使用哪个字段 + let field_name = if let Value::Object(node_obj) = node_value { + if let Some(Value::String(class_type)) = node_obj.get("class_type") { + if class_type == "String" { + "value" + } else { + "text" + } + } else { + "text" + } + } else { + "text" + }; + replacements.push(WorkflowNodeReplacement { node_id: node_id.clone(), - input_field: "text".to_string(), + input_field: field_name.to_string(), value: Value::String(prompt.to_string()), }); } "negative" => { let neg_prompt = negative_prompt.unwrap_or(""); + + // 根据节点类型决定使用哪个字段 + let field_name = if let Value::Object(node_obj) = node_value { + if let Some(Value::String(class_type)) = node_obj.get("class_type") { + if class_type == "String" { + "value" + } else { + "text" + } + } else { + "text" + } + } else { + "text" + }; + replacements.push(WorkflowNodeReplacement { node_id: node_id.clone(), - input_field: "text".to_string(), + input_field: field_name.to_string(), value: Value::String(neg_prompt.to_string()), }); } @@ -438,7 +469,16 @@ impl ComfyUIService { .map_err(|e| ComfyUIError::NetworkError(format!("解析响应失败: {}", e)))?; if let Some(errors) = prompt_response.node_errors { - return Err(ComfyUIError::WorkflowError(format!("节点错误: {}", errors))); + // 检查是否真的有错误(不是空对象) + if let Value::Object(error_map) = &errors { + if !error_map.is_empty() { + return Err(ComfyUIError::WorkflowError(format!("节点错误: {}", errors))); + } + } else if errors != Value::Object(serde_json::Map::new()) { + return Err(ComfyUIError::WorkflowError(format!("节点错误: {}", errors))); + } + // 如果是空对象 {} 则不认为是错误 + info!("收到空的节点错误对象,继续执行"); } info!("工作流提交成功,提示 ID: {}", prompt_response.prompt_id);