فهرست منبع

fix(core/api): cleanup before exit (#5765)

Amr Bashir 2 سال پیش
والد
کامیت
0f26960891
2فایلهای تغییر یافته به همراه8 افزوده شده و 2 حذف شده
  1. 5 0
      .changes/core-exit-endpoint-cleanup.md
  2. 3 2
      core/tauri/src/endpoints/process.rs

+ 5 - 0
.changes/core-exit-endpoint-cleanup.md

@@ -0,0 +1,5 @@
+---
+"tauri": "patch"
+---
+
+Cleanup sidecar and tray icons when calling `app.exit()` from JS.

+ 3 - 2
core/tauri/src/endpoints/process.rs

@@ -37,11 +37,12 @@ impl Cmd {
   }
 
   #[module_command_handler(process_exit)]
-  fn exit<R: Runtime>(_context: InvokeContext<R>, exit_code: i32) -> super::Result<()> {
+  fn exit<R: Runtime>(context: InvokeContext<R>, exit_code: i32) -> super::Result<()> {
     // would be great if we can have a handler inside tauri
     // who close all window and emit an event that user can catch
     // if they want to process something before closing the app
-    std::process::exit(exit_code);
+    context.window.app_handle.exit(exit_code);
+    Ok(())
   }
 }