From 398edd6e8609b14054f358be111374cb5dc01919 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=BE=B7=E5=AE=87?= Date: Sat, 12 Sep 2026 14:48:00 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=86=E5=88=86=E7=A6=BB=E7=8A=B6=E6=80=81?= =?UTF-8?q?=E5=BA=8F=E5=88=97=E5=8C=96=E7=A7=BB=E5=85=A5=E9=98=BB=E5=A1=9E?= =?UTF-8?q?=E4=BB=BB=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 避免在异步执行器线程同步格式化大型 separation state。 --- .../src/ui_editor/commands/separation/persistence.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/apps/ai-game-creator-shell/src-tauri/src/ui_editor/commands/separation/persistence.rs b/apps/ai-game-creator-shell/src-tauri/src/ui_editor/commands/separation/persistence.rs index 637722fa1..9275b5523 100644 --- a/apps/ai-game-creator-shell/src-tauri/src/ui_editor/commands/separation/persistence.rs +++ b/apps/ai-game-creator-shell/src-tauri/src/ui_editor/commands/separation/persistence.rs @@ -47,9 +47,12 @@ pub async fn write_separation_state(path: PathBuf, state: &SeparationState) -> R app_log!("ui_separation.error stage=state_write reason=schema_mismatch"); return Err("不支持的 separation state schema".to_string()); } - let state = serde_json::to_vec_pretty(state) - .map_err(|error| format!("序列化 separation state 失败:{error}"))?; - tokio::task::spawn_blocking(move || write_separation_state_blocking(&path, &state)) + let owned = state.clone(); + tokio::task::spawn_blocking(move || { + let bytes = serde_json::to_vec_pretty(&owned) + .map_err(|error| format!("序列化 separation state 失败:{error}"))?; + write_separation_state_blocking(&path, &bytes) + }) .await .map_err(|error| format!("写入 separation state 任务失败:{error}"))? }