Skip to content

Commit

Permalink
fix: the application does not exit directly as expected
Browse files Browse the repository at this point in the history
Signed-off-by: 1111mp <The1111mp@outlook.com>
  • Loading branch information
1111mp committed Nov 22, 2024
1 parent 67f735a commit 8352e43
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
1 change: 0 additions & 1 deletion src-tauri/src/cmds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,5 +195,4 @@ pub fn restart(app_handle: tauri::AppHandle) {
#[tauri::command]
pub fn exit_app(app_handle: tauri::AppHandle) {
app_handle.exit(0);
std::process::exit(0);
}
19 changes: 8 additions & 11 deletions src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,23 +98,20 @@ fn main() -> tauri::Result<()> {
let app = builder.build(tauri::generate_context!())?;

app.run(|app_handle, err| match err {
tauri::RunEvent::ExitRequested { api, .. } => {
let closer = Config::settings()
.data()
.get_closer()
.unwrap_or("minimize".to_string());

if closer == "minimize" {
api.prevent_exit();
return;
}

tauri::RunEvent::ExitRequested { .. } => {
let _ = app_handle.save_window_state(StateFlags::default());
}
tauri::RunEvent::WindowEvent { label, event, .. } => {
if label == "main" {
match event {
tauri::WindowEvent::CloseRequested { api, .. } => {
let closer = Config::settings()
.data()
.get_closer()
.unwrap_or("minimize".to_string());
if closer == "close" {
return;
}
// CloseRequested Event
api.prevent_close();
if let Some(window) = core::handle::Handle::global().get_window() {
Expand Down

0 comments on commit 8352e43

Please sign in to comment.