main.rs 1020 B

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