From 1eb4bd5ec0c89a3043a5b6325b7787f8f4a483e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=BE=B7=E5=AE=87?= Date: Thu, 10 Sep 2026 19:03:29 +0800 Subject: [PATCH] =?UTF-8?q?=E6=98=8E=E7=A1=AE=E6=8B=92=E7=BB=9D=E6=97=A0?= =?UTF-8?q?=E6=95=88=E7=9A=84=E5=A4=84=E7=90=86=E5=9B=BE=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E5=9C=B0=E5=9D=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 处理图缺少 data URL 分隔符时直接返回格式错误。 避免先写入空文件再在后续裁切阶段暴露误导性错误。 --- .../src/ui_editor/commands/separation/workflow.rs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/apps/ai-game-creator-shell/src-tauri/src/ui_editor/commands/separation/workflow.rs b/apps/ai-game-creator-shell/src-tauri/src/ui_editor/commands/separation/workflow.rs index 771cec10a..da0c9e6b0 100644 --- a/apps/ai-game-creator-shell/src-tauri/src/ui_editor/commands/separation/workflow.rs +++ b/apps/ai-game-creator-shell/src-tauri/src/ui_editor/commands/separation/workflow.rs @@ -248,13 +248,12 @@ async fn write_processed_image_inner(processed_url: String, target: PathBuf) -> processed_url.chars().count() ); tokio::task::spawn_blocking(move || { + let encoded = processed_url + .split_once(',') + .map(|(_, data)| data) + .ok_or_else(|| "处理图 data URL 无效".to_string())?; let processed_bytes = base64::engine::general_purpose::STANDARD - .decode( - processed_url - .split_once(',') - .map(|(_, data)| data) - .unwrap_or_default(), - ) + .decode(encoded) .map_err(|error| format!("解析处理图失败:{error}"))?; let byte_len = processed_bytes.len(); fs::write(&target, processed_bytes)