fix: avoid setting login item repeatedly, close #326

This commit is contained in:
GyDi 2022-12-23 22:39:27 +08:00
parent 8bad2c2113
commit 051be927cd
No known key found for this signature in database
GPG Key ID: 9C3AD40F1F99880A

View File

@ -182,13 +182,22 @@ impl Sysopt {
return Ok(());
}
// macos每次启动都更新登录项避免重复设置登录项
#[cfg(target_os = "macos")]
let _ = auto.disable();
{
if enable && !auto.is_enabled().unwrap_or(false) {
// 避免重复设置登录项
let _ = auto.disable();
auto.enable()?;
} else if !enable {
let _ = auto.disable();
}
}
#[cfg(not(target_os = "macos"))]
if enable {
auto.enable()?;
}
*self.auto_launch.lock() = Some(auto);
Ok(())