main.rs 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. // Copyright 2019-2024 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::{LogicalPosition, LogicalSize, WebviewUrl};
  6. fn main() {
  7. tauri::Builder::default()
  8. .setup(|app| {
  9. let width = 800.;
  10. let height = 600.;
  11. let window = tauri::window::WindowBuilder::new(app, "main")
  12. .inner_size(width, height)
  13. .build()?;
  14. let _webview1 = window.add_child(
  15. tauri::webview::WebviewBuilder::new("main1", WebviewUrl::App(Default::default()))
  16. .auto_resize(),
  17. LogicalPosition::new(0., 0.),
  18. LogicalSize::new(width / 2., height / 2.),
  19. )?;
  20. let _webview2 = window.add_child(
  21. tauri::webview::WebviewBuilder::new(
  22. "main2",
  23. WebviewUrl::External("https://github.com/tauri-apps/tauri".parse().unwrap()),
  24. )
  25. .auto_resize(),
  26. LogicalPosition::new(width / 2., 0.),
  27. LogicalSize::new(width / 2., height / 2.),
  28. )?;
  29. let _webview3 = window.add_child(
  30. tauri::webview::WebviewBuilder::new(
  31. "main3",
  32. WebviewUrl::External("https://tauri.app".parse().unwrap()),
  33. )
  34. .auto_resize(),
  35. LogicalPosition::new(0., height / 2.),
  36. LogicalSize::new(width / 2., height / 2.),
  37. )?;
  38. let _webview4 = window.add_child(
  39. tauri::webview::WebviewBuilder::new(
  40. "main4",
  41. WebviewUrl::External("https://twitter.com/TauriApps".parse().unwrap()),
  42. )
  43. .auto_resize(),
  44. LogicalPosition::new(width / 2., height / 2.),
  45. LogicalSize::new(width / 2., height / 2.),
  46. )?;
  47. Ok(())
  48. })
  49. .run(tauri::generate_context!(
  50. "../../examples/multiwebview/tauri.conf.json"
  51. ))
  52. .expect("error while running tauri application");
  53. }