File size: 1,910 Bytes
2d8be8f | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | // Copyright 2019-2024 Tauri Programme within The Commons Conservancy
// SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: MIT
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
use tauri::{LogicalPosition, LogicalSize, WebviewUrl};
fn main() {
tauri::Builder::default()
.setup(|app| {
let width = 800.;
let height = 600.;
let window = tauri::window::WindowBuilder::new(app, "main")
.inner_size(width, height)
.build()?;
let _webview1 = window.add_child(
tauri::webview::WebviewBuilder::new("main1", WebviewUrl::App(Default::default()))
.auto_resize(),
LogicalPosition::new(0., 0.),
LogicalSize::new(width / 2., height / 2.),
)?;
let _webview2 = window.add_child(
tauri::webview::WebviewBuilder::new(
"main2",
WebviewUrl::External("https://github.com/tauri-apps/tauri".parse().unwrap()),
)
.auto_resize(),
LogicalPosition::new(width / 2., 0.),
LogicalSize::new(width / 2., height / 2.),
)?;
let _webview3 = window.add_child(
tauri::webview::WebviewBuilder::new(
"main3",
WebviewUrl::External("https://tauri.app".parse().unwrap()),
)
.auto_resize(),
LogicalPosition::new(0., height / 2.),
LogicalSize::new(width / 2., height / 2.),
)?;
let _webview4 = window.add_child(
tauri::webview::WebviewBuilder::new(
"main4",
WebviewUrl::External("https://twitter.com/TauriApps".parse().unwrap()),
)
.auto_resize(),
LogicalPosition::new(width / 2., height / 2.),
LogicalSize::new(width / 2., height / 2.),
)?;
Ok(())
})
.run(tauri::generate_context!(
"../../examples/multiwebview/tauri.conf.json"
))
.expect("error while running tauri application");
}
|