Is there any way to get tauri::App outside main function?


fn main() {
    let app = tauri::Builder::default()
        .invoke_handler(tauri::generate_handler![close_splashscreen])
        .build(tauri::generate_context!())
        .expect("error while building tauri application");

    test(&app);

    app.run(|_app_handle, event| match event {
        tauri::RunEvent::ExitRequested { api, .. } => {
            api.prevent_exit();
        }
        _ => {}
    });
}

fn test(app: &tauri::App) {
    let window = app.get_window("main").unwrap();
    if !window.is_devtools_open() {
        window.open_devtools();
    }
}

I tried to get app in the main function.Is it possable to do this outside main?For example,make a function to change menu text in other file?

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.