mirror of
https://github.com/farion1231/cc-switch.git
synced 2026-07-24 12:44:18 +08:00
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.
This commit is contained in:
@@ -7,7 +7,14 @@ fn get_auto_launch() -> Result<AutoLaunch, AppError> {
|
|||||||
let app_path =
|
let app_path =
|
||||||
std::env::current_exe().map_err(|e| AppError::Message(format!("无法获取应用路径: {e}")))?;
|
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]);
|
let auto_launch = AutoLaunch::new(app_name, &app_path.to_string_lossy(), false, &[] as &[&str]);
|
||||||
|
|
||||||
Ok(auto_launch)
|
Ok(auto_launch)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user