tauri-apps / tauri

Build smaller, faster, and more secure desktop and mobile applications with a web frontend.
https://tauri.app
Apache License 2.0
85.36k stars 2.58k forks source link

[feat] It is recommended to add the configuration item whether to close the program after closing all Windows #11759

Closed GuoJikun closed 15 hours ago

GuoJikun commented 1 day ago

Describe the problem

The program is closed after closing all Windows

Describe the solution you'd like

It is recommended to add the configuration item whether to close the program after closing all Windows

Alternatives considered

No response

Additional context

No response

amrbashir commented 15 hours ago

you can do something like this

    tauri::Builder::default()
        .build(tauri::generate_context!())
        .expect("error while running tauri application")
        .run(|app, event| {
            if let tauri::RunEvent::ExitRequested { api, code, .. } = event {
                if code.is_none() {
                    api.prevent_exit();
                }
            }
        });
GuoJikun commented 3 hours ago

you can do something like this

    tauri::Builder::default()
        .build(tauri::generate_context!())
        .expect("error while running tauri application")
        .run(|app, event| {
            if let tauri::RunEvent::ExitRequested { api, code, .. } = event {
                if code.is_none() {
                    api.prevent_exit();
                }
            }
        });

thanks