From fbdfcc8abe3ace5bc13623efd3648b827d42517b Mon Sep 17 00:00:00 2001 From: Julian Freeman Date: Sat, 4 Apr 2026 18:24:34 -0400 Subject: [PATCH] support delay --- src-tauri/src/lib.rs | 25 +++++++++++++++++++++---- src-tauri/src/winget.rs | 12 ++++++++---- 2 files changed, 29 insertions(+), 8 deletions(-) diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index 32d9331..1510cce 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -210,8 +210,17 @@ async fn execute_post_install(handle: &AppHandle, log_id: &str, steps: Vec *delay_ms, + PostInstallStep::FileCopy { delay_ms, .. } => *delay_ms, + PostInstallStep::FileDelete { delay_ms, .. } => *delay_ms, + PostInstallStep::Command { delay_ms, .. } => *delay_ms, + }; + match step { - PostInstallStep::RegistryBatch { root, base_path, values } => { + PostInstallStep::RegistryBatch { root, base_path, values, .. } => { emit_log(handle, log_id, "Registry Update", &format!("{}Applying batch registry settings to {}...", step_prefix, base_path), "info"); let hive = match root.as_str() { "HKCU" => RegKey::predef(HKEY_CURRENT_USER), @@ -253,7 +262,7 @@ async fn execute_post_install(handle: &AppHandle, log_id: &str, steps: Vec { + PostInstallStep::FileCopy { src, dest, .. } => { let dest_path = expand_win_path(&dest); let src_is_url = src.starts_with("http://") || src.starts_with("https://"); @@ -289,7 +298,7 @@ async fn execute_post_install(handle: &AppHandle, log_id: &str, steps: Vec { + PostInstallStep::FileDelete { path, .. } => { let full_path = expand_win_path(&path); emit_log(handle, log_id, "File Delete", &format!("{}Deleting {:?}...", step_prefix, full_path), "info"); if full_path.exists() { @@ -302,7 +311,7 @@ async fn execute_post_install(handle: &AppHandle, log_id: &str, steps: Vec { + PostInstallStep::Command { run, .. } => { emit_log(handle, log_id, "Command Execution", &format!("{}Executing: {}", step_prefix, run), "info"); let output = Command::new("cmd") .args(["/C", &run]) @@ -324,6 +333,14 @@ async fn execute_post_install(handle: &AppHandle, log_id: &str, steps: Vec 0 { + emit_log(handle, log_id, "Post-Install", &format!("Waiting for {}ms...", ms), "info"); + tokio::time::sleep(std::time::Duration::from_millis(ms)).await; + } + } } Ok(()) } diff --git a/src-tauri/src/winget.rs b/src-tauri/src/winget.rs index 3d9624b..d2ae47e 100644 --- a/src-tauri/src/winget.rs +++ b/src-tauri/src/winget.rs @@ -16,22 +16,26 @@ pub struct RegistryValue { pub enum PostInstallStep { #[serde(rename = "registry_batch")] RegistryBatch { - root: String, // "HKCU", "HKLM" + root: String, base_path: String, values: HashMap, + delay_ms: Option, }, #[serde(rename = "file_copy")] FileCopy { - src: String, // 支持 URL 或本地路径(含环境变量) - dest: String, // 目标路径(含环境变量) + src: String, + dest: String, + delay_ms: Option, }, #[serde(rename = "file_delete")] FileDelete { - path: String, // 要删除的文件路径(含环境变量) + path: String, + delay_ms: Option, }, #[serde(rename = "command")] Command { run: String, + delay_ms: Option, }, }