99
1010#[ cfg( any( windows, target_os = "macos" ) ) ]
1111use tauri:: Manager ;
12- use tauri:: { command, window, AppHandle , WindowBuilder , WindowUrl } ;
12+ use tauri:: { command, window:: WindowBuilder , AppHandle , WindowUrl } ;
1313
1414#[ command]
1515fn create_child_window ( id : String , app : AppHandle ) {
1616 #[ cfg( any( windows, target_os = "macos" ) ) ]
1717 let main = app. get_window ( "main" ) . unwrap ( ) ;
1818
19- let child = window :: WindowBuilder :: new ( & app, id, WindowUrl :: default ( ) )
19+ let child = WindowBuilder :: new ( & app, id, WindowUrl :: default ( ) )
2020 . title ( "Child" )
2121 . inner_size ( 400.0 , 300.0 ) ;
2222
@@ -37,17 +37,13 @@ fn main() {
3737 } ) ;
3838 } )
3939 . invoke_handler ( tauri:: generate_handler![ create_child_window] )
40- . create_window (
41- "main" . to_string ( ) ,
42- WindowUrl :: default ( ) ,
43- |window_builder, webview_attributes| {
44- (
45- window_builder. title ( "Main" ) . inner_size ( 600.0 , 400.0 ) ,
46- webview_attributes,
47- )
48- } ,
49- )
50- . unwrap ( ) // safe to unwrap: window label is valid
40+ . setup ( |app| {
41+ WindowBuilder :: new ( app, "main" . to_string ( ) , WindowUrl :: default ( ) )
42+ . title ( "Main" )
43+ . inner_size ( 600.0 , 400.0 )
44+ . build ( ) ?;
45+ Ok ( ( ) )
46+ } ) // safe to unwrap: window label is valid
5147 . run ( tauri:: generate_context!(
5248 "../../examples/parent-window/tauri.conf.json"
5349 ) )
0 commit comments