Skip to content
Snippets Groups Projects
Unverified Commit 2d95f2b0 authored by GyDi's avatar GyDi Committed by GitHub
Browse files

fix: auto launch path

parent ec41bb9c
No related branches found
No related tags found
No related merge requests found
...@@ -133,37 +133,31 @@ impl Verge { ...@@ -133,37 +133,31 @@ impl Verge {
} }
/// init the auto launch /// init the auto launch
pub fn init_launch(&mut self) { pub fn init_launch(&mut self) -> Result<()> {
let app_exe = current_exe().unwrap(); let app_exe = current_exe().unwrap();
let app_exe = dunce::canonicalize(app_exe).unwrap(); let app_exe = dunce::canonicalize(app_exe).unwrap();
let app_name = app_exe.file_stem().unwrap().to_str().unwrap(); let app_name = app_exe.file_stem().unwrap().to_str().unwrap();
let app_path = app_exe.as_os_str().to_str().unwrap(); let app_path = app_exe.as_os_str().to_str().unwrap();
// fix issue #26
#[cfg(target_os = "windows")]
let app_path = format!("\"{app_path}\"");
#[cfg(target_os = "windows")]
let app_path = app_path.as_str();
let auto = AutoLaunchBuilder::new() let auto = AutoLaunchBuilder::new()
.set_app_name(app_name) .set_app_name(app_name)
.set_app_path(app_path) .set_app_path(app_path)
.build(); .build();
self.auto_launch = Some(auto); if let Some(enable) = self.config.enable_auto_launch.as_ref() {
} // fix issue #26
if *enable {
/// sync the startup when run the app auto.enable()?;
pub fn sync_launch(&self) -> Result<()> { }
let enable = self.config.enable_auto_launch.clone().unwrap_or(false);
if !enable {
return Ok(());
}
if self.auto_launch.is_none() {
bail!("should init the auto launch first");
} }
let auto_launch = self.auto_launch.clone().unwrap(); self.auto_launch = Some(auto);
let is_enabled = auto_launch.is_enabled().unwrap_or(false);
if !is_enabled {
auto_launch.enable()?;
}
Ok(()) Ok(())
} }
......
...@@ -38,8 +38,7 @@ pub fn resolve_setup(app: &App) { ...@@ -38,8 +38,7 @@ pub fn resolve_setup(app: &App) {
clash.tun_mode(true).unwrap(); clash.tun_mode(true).unwrap();
} }
verge.init_launch(); log_if_err!(verge.init_launch());
log_if_err!(verge.sync_launch());
} }
/// reset system proxy /// reset system proxy
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment