diff --git a/pages/index.vue b/pages/index.vue index c21f2a7..4a8e50f 100644 --- a/pages/index.vue +++ b/pages/index.vue @@ -226,7 +226,7 @@ 强制中转 @@ -595,18 +595,16 @@ const compatibleInitAutoStart = async () => { try { - const is_enable = await tauriAutoStart.isEnabled(); - if (is_enable) { - await tauriAutoStart.disable(); - await invoke("spawn_autostart", { enabled: true }); - const is_enable_by_task = (await invoke("autostart_is_enabled")) as boolean; - config.autoStart = is_enable_by_task; - } else { - const is_enable_by_task = (await invoke("autostart_is_enabled")) as boolean; - config.autoStart = is_enable_by_task; + const is_enable_by_task = (await invoke("autostart_is_enabled")) as boolean; + if (is_enable_by_task) { + await tauriAutoStart.enable(); + await invoke("spawn_autostart", { enabled: false }); } + const is_enable = await tauriAutoStart.isEnabled(); + config.autoStart = is_enable; } catch (err) { await invoke("spawn_autostart", { enabled: false }); + await tauriAutoStart.disable(); config.autoStart = false; } };