简体   繁体   中英

Tauri : How to open webpage when cliking on the menu

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 !

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM