feat: sync auto-start status

This commit is contained in:
wonfen
2025-03-17 09:48:44 +08:00
parent 697d200ffe
commit 6239f81f36
6 changed files with 30 additions and 2 deletions

View File

@@ -70,6 +70,13 @@ pub fn get_app_dir() -> CmdResult<String> {
Ok(app_home_dir)
}
/// 获取当前自启动状态
#[tauri::command]
pub fn get_auto_launch_status() -> CmdResult<bool> {
use crate::core::sysopt::Sysopt;
wrap_err!(Sysopt::global().get_launch_status())
}
/// 下载图标缓存
#[tauri::command]
pub async fn download_icon_cache(url: String, name: String) -> CmdResult<String> {

View File

@@ -229,6 +229,13 @@ impl Sysopt {
Ok(())
}
/// 获取当前自启动的实际状态
pub fn get_launch_status(&self) -> Result<bool> {
let app_handle = Handle::global().app_handle().unwrap();
let autostart_manager = app_handle.autolaunch();
Ok(autostart_manager.is_enabled()?)
}
fn guard_proxy(&self) {
let _lock = self.guard_state.lock();

View File

@@ -154,6 +154,7 @@ pub fn run() {
cmd::get_running_mode,
cmd::install_service,
cmd::get_app_uptime,
cmd::get_auto_launch_status,
// clash
cmd::get_clash_info,
cmd::patch_clash_config,