main.rs 958 B

1234567891011121314151617181920212223242526272829303132
  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. .create_window(
  18. "Rust".to_string(),
  19. tauri::WindowUrl::App("index.html".into()),
  20. |window_builder, webview_attributes| {
  21. (window_builder.title("Tauri - Rust"), webview_attributes)
  22. },
  23. )
  24. .unwrap() // safe to unwrap: window label is valid
  25. .run(tauri::generate_context!(
  26. "../../examples/multiwindow/tauri.conf.json"
  27. ))
  28. .expect("failed to run tauri application");
  29. }