From 557f5fe364df76484947711b6340989db230227b Mon Sep 17 00:00:00 2001 From: GyDi Date: Mon, 25 Apr 2022 20:00:11 +0800 Subject: [PATCH] fix: adjust something --- src-tauri/src/cmds.rs | 6 ++++-- src-tauri/src/main.rs | 3 +-- src-tauri/src/utils/resolve.rs | 5 ++++- src/components/setting/service-mode.tsx | 4 ++-- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src-tauri/src/cmds.rs b/src-tauri/src/cmds.rs index d4ca786..2a42c6b 100644 --- a/src-tauri/src/cmds.rs +++ b/src-tauri/src/cmds.rs @@ -263,8 +263,10 @@ pub mod service { #[tauri::command] pub async fn install_service() -> Result<(), String> { - wrap_err!(crate::core::Service::install_service().await)?; - wrap_err!(crate::core::Service::start_service().await) + log_if_err!(crate::core::Service::install_service().await); + let ret = wrap_err!(crate::core::Service::start_service().await); + log::info!("clash verge service started successfully"); + ret } #[tauri::command] diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index 8f17feb..8abe5e7 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -85,8 +85,7 @@ fn main() -> std::io::Result<()> { } "quit" => { resolve::resolve_reset(app_handle); - api::process::kill_children(); - std::process::exit(0); + app_handle.exit(0); } _ => {} }, diff --git a/src-tauri/src/utils/resolve.rs b/src-tauri/src/utils/resolve.rs index a7d6906..0c25953 100644 --- a/src-tauri/src/utils/resolve.rs +++ b/src-tauri/src/utils/resolve.rs @@ -22,8 +22,11 @@ pub fn resolve_setup(app: &App) { pub fn resolve_reset(app_handle: &AppHandle) { let core = app_handle.state::(); let mut sysopt = core.sysopt.lock(); - sysopt.reset_sysproxy(); + drop(sysopt); + + let mut service = core.service.lock(); + crate::log_if_err!(service.stop()); } /// customize the window theme diff --git a/src/components/setting/service-mode.tsx b/src/components/setting/service-mode.tsx index 768af80..46f5cbf 100644 --- a/src/components/setting/service-mode.tsx +++ b/src/components/setting/service-mode.tsx @@ -41,8 +41,8 @@ const ServiceMode = (props: Props) => { try { await installService(); mutate("checkService"); - Notice.success("Service installed successfully"); onClose(); + Notice.success("Service installed successfully"); } catch (err: any) { mutate("checkService"); onError(err); @@ -56,9 +56,9 @@ const ServiceMode = (props: Props) => { } await uninstallService(); - Notice.success("Service uninstalled successfully"); mutate("checkService"); onClose(); + Notice.success("Service uninstalled successfully"); } catch (err: any) { mutate("checkService"); onError(err);