main.rs 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. // Copyright 2019-2021 Tauri Programme within The Commons Conservancy
  2. // SPDX-License-Identifier: Apache-2.0
  3. // SPDX-License-Identifier: MIT
  4. #![cfg_attr(
  5. all(not(debug_assertions), target_os = "windows"),
  6. windows_subsystem = "windows"
  7. )]
  8. use tauri::WindowBuilder;
  9. fn main() {
  10. let context = tauri::generate_context!("../../examples/multiwindow/tauri.conf.json");
  11. tauri::Builder::default()
  12. .menu(if cfg!(target_os = "macos") {
  13. tauri::Menu::os_default(&context.package_info().name)
  14. } else {
  15. tauri::Menu::default()
  16. })
  17. .on_page_load(|window, _payload| {
  18. let label = window.label().to_string();
  19. window.listen("clicked".to_string(), move |_payload| {
  20. println!("got 'clicked' event on window '{}'", label);
  21. });
  22. })
  23. .setup(|app| {
  24. WindowBuilder::new(
  25. app,
  26. "Rust".to_string(),
  27. tauri::WindowUrl::App("index.html".into()),
  28. )
  29. .title("Tauri - Rust")
  30. .build()?;
  31. Ok(())
  32. })
  33. .run(context)
  34. .expect("failed to run tauri application");
  35. }