main.rs 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. // Copyright 2019-2022 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. tauri::Builder::default()
  11. .on_page_load(|window, _payload| {
  12. let label = window.label().to_string();
  13. window.listen("clicked".to_string(), move |_payload| {
  14. println!("got 'clicked' event on window '{label}'");
  15. });
  16. })
  17. .setup(|app| {
  18. #[allow(unused_mut)]
  19. let mut builder = WindowBuilder::new(
  20. app,
  21. "Rust".to_string(),
  22. tauri::WindowUrl::App("index.html".into()),
  23. );
  24. #[cfg(target_os = "macos")]
  25. {
  26. builder = builder.tabbing_identifier("Rust");
  27. }
  28. let _window = builder.title("Tauri - Rust").build()?;
  29. Ok(())
  30. })
  31. .run(tauri::generate_context!(
  32. "../../examples/multiwindow/tauri.conf.json"
  33. ))
  34. .expect("failed to run tauri application");
  35. }