main.rs 1.1 KB

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