From 299877b1976f7c261ee7a20b8098d951f04d2901 Mon Sep 17 00:00:00 2001 From: kdletters Date: Fri, 11 Sep 2026 23:25:31 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20Tauri=20dev=20=E6=8F=92?= =?UTF-8?q?=E4=BB=B6=E8=B5=84=E6=BA=90=E8=87=AA=E8=A7=A6=E5=8F=91=E9=87=8D?= =?UTF-8?q?=E5=BB=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit build.rs 只在内容变化时落盘插件资源,避免构建产物触发下一轮重建 新增应用目录与 src-tauri 的 .taurignore,把 resources/plugins 排除出 dev 监听 --- apps/ai-game-creator-shell/.taurignore | 4 ++++ apps/ai-game-creator-shell/src-tauri/.taurignore | 4 ++++ apps/ai-game-creator-shell/src-tauri/build.rs | 16 +++++++++++++++- 3 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 apps/ai-game-creator-shell/.taurignore create mode 100644 apps/ai-game-creator-shell/src-tauri/.taurignore diff --git a/apps/ai-game-creator-shell/.taurignore b/apps/ai-game-creator-shell/.taurignore new file mode 100644 index 000000000..8ec126556 --- /dev/null +++ b/apps/ai-game-creator-shell/.taurignore @@ -0,0 +1,4 @@ +# resources/plugins 由 build.rs 从 plugins/ 复制生成,属于构建产物。 +# 它在 dev 监听范围内,重新生成会让 Tauri dev 误判为源码改动而触发 +# “构建 -> 监听 -> 再构建”的自触发循环。 +resources/plugins/ diff --git a/apps/ai-game-creator-shell/src-tauri/.taurignore b/apps/ai-game-creator-shell/src-tauri/.taurignore new file mode 100644 index 000000000..8ec126556 --- /dev/null +++ b/apps/ai-game-creator-shell/src-tauri/.taurignore @@ -0,0 +1,4 @@ +# resources/plugins 由 build.rs 从 plugins/ 复制生成,属于构建产物。 +# 它在 dev 监听范围内,重新生成会让 Tauri dev 误判为源码改动而触发 +# “构建 -> 监听 -> 再构建”的自触发循环。 +resources/plugins/ diff --git a/apps/ai-game-creator-shell/src-tauri/build.rs b/apps/ai-game-creator-shell/src-tauri/build.rs index 4382abeef..e9f6642e0 100644 --- a/apps/ai-game-creator-shell/src-tauri/build.rs +++ b/apps/ai-game-creator-shell/src-tauri/build.rs @@ -293,6 +293,20 @@ fn stage_plugin_workspace(manifest_dir: &std::path::Path) { } } +#[cfg(windows)] +fn stage_plugin_file(source: &std::path::Path, destination: &std::path::Path) { + let Ok(bytes) = std::fs::read(source) else { + return; + }; + if std::fs::read(destination).is_ok_and(|existing| existing == bytes) { + return; + } + if let Some(parent) = destination.parent() { + std::fs::create_dir_all(parent).expect("创建插件资源目录失败"); + } + std::fs::write(destination, bytes).expect("复制插件资源失败"); +} + #[cfg(windows)] fn copy_plugin_tree(source: &std::path::Path, destination: &std::path::Path) { let entries = match std::fs::read_dir(source) { @@ -317,7 +331,7 @@ fn copy_plugin_tree(source: &std::path::Path, destination: &std::path::Path) { if name.contains(".test.") { continue; } - copy_plugin_file(&path, &target); + stage_plugin_file(&path, &target); } } }