#Supporting multiple Tauri configs in the same binary

6 messages · Page 1 of 1 (latest)

sterile nacelle
#

Hi,
The way we're using Tauri, we have a binary that can execute in two modes:

  • the first mode spawns another copy of the binary in the second mode, and watches for errors. If any are detected, we show an error message in HTML/CSS with Tauri.
  • The second mode is the actual application.

Currently both the first and second mode point to a single React app that uses the Tauri command API to figure out which mode it's in. But I'd like to simplify the first mode to just an HTML w/o Javascript page that is completely ignorant of Tauri. Ideally I could just generate the HTML as a string and tell Tauri "please just show this to the user".

I'm relatively new to Tauri and can't figure out how to accomplish this. Advice?

#

I think this might work?

if (error) {
            tauri::Builder::default()
                .setup(|app| {
                    let window = tauri::WindowBuilder::new(
                        app,
                        "label",
                        tauri::WindowUrl::App("http://localhost:8080/crash_app.html".into()),
                    )
                    .build()?;
                    window.show().unwrap();
                    Ok(())
                })
                .run(tauri::generate_context!())
                .unwrap();
        } else {
            // normal tauri stuff here
        }
sterile nacelle
#

The above snippet produced two windows, the main one and the crash_app.html one. Is there a way I can tell the main window to set it's location to a specific URL in that setup function? Right now I'm just closing it and opening a new one like the above snippet.

oak brook
#

honestly i would just remove the window from tauri.conf.json and also spawn that from rust. Feels the most clean to me.

#

you could probablyyy do something like this in the setup hook. ```rs
let main_window = app.get_window("main").unwrap();
main_window.eval("window.location.replace('http://localhost:8080/crash_html')");

Assuming the setup hook runs early enough.