Tauri : How to open webpage when cliking on the menu
Asked Answered
S

2

6

I'm trying to make a small tauri app with the same menu on the top of each page. I followed this tutorial, "Adding the menu to all windows" section. I can see the menu, I can quit the app with it, but I can't find out how to go to another hmtl page when cliked.

I've got this piece of code but I have no idea what to put under "accel"

.on_menu_event(|event| {
      match event.menu_item_id() {
        "quit" => {
          std::process::exit(0);
        }
        "close" => {
          event.window().close().unwrap();
          
        }
        "accel" => {
          //not working, as you can imagine
          //tauri::WindowUrl::App("index.html".into());
          //I would like tauri to display index.html in the main window
        }
        _ => {}
      }
    })

Does someone has an idea on how to do that ? I've found dozen of example code with menus but none showed what I'm looking for (or I'm unable to point out the line I need)

Thanks for your help !

Starryeyed answered 10/3, 2022 at 19:35 Comment(0)
S
3

I finally got the answer from the tauri discord chat, I hope it can be useful to someone?

window.eval("window.location.replace('your.url')"); made the job

Starryeyed answered 17/3, 2022 at 17:25 Comment(0)
T
0

You must config in Cargo.toml

tauri = { version = "x.y.z", features = [..., "shell-open"] }
Thyratron answered 26/4, 2023 at 10:24 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.