@@ -79,6 +79,7 @@ pub async fn init_ads_window<R: Runtime>(
7979 override_shown : bool ,
8080) -> crate :: api:: Result < ( ) > {
8181 use tauri:: WebviewUrl ;
82+ const LINK_SCRIPT : & str = include_str ! ( "ads-init.js" ) ;
8283
8384 let state = app. state :: < RwLock < AdsState > > ( ) ;
8485 let mut state = state. write ( ) . await ;
@@ -101,42 +102,25 @@ pub async fn init_ads_window<R: Runtime>(
101102 webview. set_position ( PhysicalPosition :: new ( -1000 , -1000 ) ) ;
102103 }
103104 } else if let Some ( window) = app. get_window ( "main" ) {
104- let webview = window. add_child (
105+ let _ = window. add_child (
105106 tauri:: webview:: WebviewBuilder :: new (
106107 "ads-window" ,
107108 WebviewUrl :: External (
108109 AD_LINK . parse ( ) . unwrap ( ) ,
109110 ) ,
110111 )
111- . initialization_script_for_all_frames ( include_str ! ( "ads-init.js" ) )
112- . user_agent ( "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36" )
113- . zoom_hotkeys_enabled ( false )
114- . transparent ( true )
115- . on_new_window ( |_ , _| tauri :: webview :: NewWindowResponse :: Deny ) ,
112+ . initialization_script ( LINK_SCRIPT )
113+ // .initialization_script_for_main_only(LINK_SCRIPT, false )
114+ . user_agent ( "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36" )
115+ . zoom_hotkeys_enabled ( false )
116+ . transparent ( true ) ,
116117 if state. shown {
117118 position
118119 } else {
119120 PhysicalPosition :: new ( -1000.0 , -1000.0 )
120121 } ,
121122 size,
122- ) ?;
123-
124- webview. with_webview ( #[ allow( unused_variables) ] |webview2| {
125- #[ cfg( windows) ]
126- {
127- use webview2_com:: Microsoft :: Web :: WebView2 :: Win32 :: ICoreWebView2_8 ;
128- use windows_core:: Interface ;
129-
130- let webview2_controller = webview2. controller ( ) ;
131- let Ok ( webview2_8) = unsafe { webview2_controller. CoreWebView2 ( ) }
132- . and_then ( |core_webview2| core_webview2. cast :: < ICoreWebView2_8 > ( ) )
133- else {
134- return ;
135- } ;
136-
137- unsafe { webview2_8. SetIsMuted ( true ) } . ok ( ) ;
138- }
139- } ) ?;
123+ ) ;
140124 }
141125 }
142126
0 commit comments