main.rs 892 B

12345678910111213141516171819202122232425262728293031323334
  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. 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. WindowBuilder::new(
  19. app,
  20. "Rust".to_string(),
  21. tauri::WindowUrl::App("index.html".into()),
  22. )
  23. .title("Tauri - Rust")
  24. .build()?;
  25. Ok(())
  26. })
  27. .run(tauri::generate_context!(
  28. "../../examples/multiwindow/tauri.conf.json"
  29. ))
  30. .expect("failed to run tauri application");
  31. }