From 2a6980417bf3ca4b53a9fc282d31606131aaad56 Mon Sep 17 00:00:00 2001 From: farion1231 Date: Fri, 28 Nov 2025 09:58:47 +0800 Subject: [PATCH] fix(auto-launch): use platform-specific API for AutoLaunch::new Windows version of auto-launch crate takes 3 arguments while Linux/macOS takes 4 (includes hidden parameter). Use conditional compilation to handle the difference. --- src-tauri/src/auto_launch.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src-tauri/src/auto_launch.rs b/src-tauri/src/auto_launch.rs index a0ae6e9c..cf677cd5 100644 --- a/src-tauri/src/auto_launch.rs +++ b/src-tauri/src/auto_launch.rs @@ -7,7 +7,14 @@ fn get_auto_launch() -> Result { let app_path = std::env::current_exe().map_err(|e| AppError::Message(format!("无法获取应用路径: {e}")))?; + // Windows 平台的 AutoLaunch::new 只接受 3 个参数 + // Linux/macOS 平台需要 4 个参数(包含 hidden 参数) + #[cfg(target_os = "windows")] + let auto_launch = AutoLaunch::new(app_name, &app_path.to_string_lossy(), &[] as &[&str]); + + #[cfg(not(target_os = "windows"))] let auto_launch = AutoLaunch::new(app_name, &app_path.to_string_lossy(), false, &[] as &[&str]); + Ok(auto_launch) }