fix(tauri): export WindowBuilder struct instead of trait, closes #3827 (#3833)

This commit is contained in:
Lucas Fernandes Nogueira 2022-03-31 10:50:33 -07:00 committed by GitHub
parent 50d135b20f
commit 985d250898
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 26 additions and 23 deletions

View File

@ -0,0 +1,5 @@
---
"tauri": patch
---
Fixes the `WindowBuilder` export.

View File

@ -211,7 +211,7 @@ pub use {
},
self::manager::Asset,
self::runtime::{
webview::{WebviewAttributes, WindowBuilder},
webview::WebviewAttributes,
window::{
dpi::{LogicalPosition, LogicalSize, PhysicalPosition, PhysicalSize, Pixel, Position, Size},
FileDropEvent,
@ -224,7 +224,7 @@ pub use {
config::{Config, WindowUrl},
Env, PackageInfo,
},
self::window::{Monitor, Window},
self::window::{Monitor, Window, WindowBuilder},
scope::*,
};

View File

@ -17,14 +17,16 @@ fn main() {
println!("got 'clicked' event on window '{}'", label);
});
})
.create_window(
"Rust".to_string(),
tauri::WindowUrl::App("index.html".into()),
|window_builder, webview_attributes| {
(window_builder.title("Tauri - Rust"), webview_attributes)
},
)
.unwrap() // safe to unwrap: window label is valid
.setup(|app| {
WindowBuilder::new(
app,
"Rust".to_string(),
tauri::WindowUrl::App("index.html".into()),
)
.title("Tauri - Rust")
.build()?;
Ok(())
})
.run(tauri::generate_context!(
"../../examples/multiwindow/tauri.conf.json"
))

View File

@ -9,14 +9,14 @@
#[cfg(any(windows, target_os = "macos"))]
use tauri::Manager;
use tauri::{command, window, AppHandle, WindowBuilder, WindowUrl};
use tauri::{command, window::WindowBuilder, AppHandle, WindowUrl};
#[command]
fn create_child_window(id: String, app: AppHandle) {
#[cfg(any(windows, target_os = "macos"))]
let main = app.get_window("main").unwrap();
let child = window::WindowBuilder::new(&app, id, WindowUrl::default())
let child = WindowBuilder::new(&app, id, WindowUrl::default())
.title("Child")
.inner_size(400.0, 300.0);
@ -37,17 +37,13 @@ fn main() {
});
})
.invoke_handler(tauri::generate_handler![create_child_window])
.create_window(
"main".to_string(),
WindowUrl::default(),
|window_builder, webview_attributes| {
(
window_builder.title("Main").inner_size(600.0, 400.0),
webview_attributes,
)
},
)
.unwrap() // safe to unwrap: window label is valid
.setup(|app| {
WindowBuilder::new(app, "main".to_string(), WindowUrl::default())
.title("Main")
.inner_size(600.0, 400.0)
.build()?;
Ok(())
}) // safe to unwrap: window label is valid
.run(tauri::generate_context!(
"../../examples/parent-window/tauri.conf.json"
))