main.rs 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  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, WindowUrl};
  9. mod commands;
  10. fn main() {
  11. tauri::Builder::default()
  12. .on_page_load(|window, _payload| {
  13. let label = window.label().to_string();
  14. window.listen("clicked".to_string(), move |_payload| {
  15. println!("got 'clicked' event on window '{}'", label);
  16. });
  17. })
  18. .invoke_handler(tauri::generate_handler![commands::create_child_window])
  19. .create_window(
  20. "main".to_string(),
  21. WindowUrl::default(),
  22. |window_builder, webview_attributes| {
  23. (
  24. window_builder.title("Main").inner_size(600.0, 400.0),
  25. webview_attributes,
  26. )
  27. },
  28. )
  29. .unwrap() // safe to unwrap: window label is valid
  30. .run(tauri::generate_context!(
  31. "../../examples/parent-window/src-tauri/tauri.conf.json"
  32. ))
  33. .expect("failed to run tauri application");
  34. }