File tree Expand file tree Collapse file tree 6 files changed +40
-0
lines changed Expand file tree Collapse file tree 6 files changed +40
-0
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ ' tauri ' : ' minor:feat'
3
+ ' tauri-runtime-wry ' : ' minor:feat'
4
+ ---
5
+
6
+ feat: add ` Webview.reload ` and ` WebviewWindow.reload `
Original file line number Diff line number Diff line change @@ -1303,6 +1303,7 @@ pub enum WebviewMessage {
1303
1303
WebviewEvent ( WebviewEvent ) ,
1304
1304
SynthesizedWindowEvent ( SynthesizedWindowEvent ) ,
1305
1305
Navigate ( Url ) ,
1306
+ Reload ,
1306
1307
Print ,
1307
1308
Close ,
1308
1309
Show ,
@@ -1466,6 +1467,17 @@ impl<T: UserEvent> WebviewDispatch<T> for WryWebviewDispatcher<T> {
1466
1467
)
1467
1468
}
1468
1469
1470
+ fn reload ( & self ) -> Result < ( ) > {
1471
+ send_user_message (
1472
+ & self . context ,
1473
+ Message :: Webview (
1474
+ * self . window_id . lock ( ) . unwrap ( ) ,
1475
+ self . webview_id ,
1476
+ WebviewMessage :: Reload ,
1477
+ ) ,
1478
+ )
1479
+ }
1480
+
1469
1481
fn print ( & self ) -> Result < ( ) > {
1470
1482
send_user_message (
1471
1483
& self . context ,
@@ -3307,6 +3319,11 @@ fn handle_user_message<T: UserEvent>(
3307
3319
log:: error!( "failed to navigate to url {}: {}" , url, e) ;
3308
3320
}
3309
3321
}
3322
+ WebviewMessage :: Reload => {
3323
+ if let Err ( e) = webview. reload ( ) {
3324
+ log:: error!( "failed to reload: {e}" ) ;
3325
+ }
3326
+ }
3310
3327
WebviewMessage :: Show => {
3311
3328
if let Err ( e) = webview. set_visible ( true ) {
3312
3329
log:: error!( "failed to change webview visibility: {e}" ) ;
Original file line number Diff line number Diff line change @@ -486,6 +486,9 @@ pub trait WebviewDispatch<T: UserEvent>: Debug + Clone + Send + Sync + Sized + '
486
486
/// Navigate to the given URL.
487
487
fn navigate ( & self , url : Url ) -> Result < ( ) > ;
488
488
489
+ /// Reloads the current page.
490
+ fn reload ( & self ) -> Result < ( ) > ;
491
+
489
492
/// Opens the dialog to prints the contents of the webview.
490
493
fn print ( & self ) -> Result < ( ) > ;
491
494
Original file line number Diff line number Diff line change @@ -558,6 +558,10 @@ impl<T: UserEvent> WebviewDispatch<T> for MockWebviewDispatcher {
558
558
Ok ( ( ) )
559
559
}
560
560
561
+ fn reload ( & self ) -> Result < ( ) > {
562
+ Ok ( ( ) )
563
+ }
564
+
561
565
fn print ( & self ) -> Result < ( ) > {
562
566
Ok ( ( ) )
563
567
}
Original file line number Diff line number Diff line change @@ -1303,6 +1303,11 @@ fn main() {
1303
1303
self . webview . dispatcher . navigate ( url) . map_err ( Into :: into)
1304
1304
}
1305
1305
1306
+ /// Reloads the current page.
1307
+ pub fn reload ( & self ) -> crate :: Result < ( ) > {
1308
+ self . webview . dispatcher . reload ( ) . map_err ( Into :: into)
1309
+ }
1310
+
1306
1311
fn is_local_url ( & self , current_url : & Url ) -> bool {
1307
1312
let uses_https = current_url. scheme ( ) == "https" ;
1308
1313
Original file line number Diff line number Diff line change @@ -1898,6 +1898,11 @@ impl<R: Runtime> WebviewWindow<R> {
1898
1898
self . webview . navigate ( url)
1899
1899
}
1900
1900
1901
+ /// Reloads the current page.
1902
+ pub fn reload ( & self ) -> crate :: Result < ( ) > {
1903
+ self . webview . reload ( )
1904
+ }
1905
+
1901
1906
/// Handles this window receiving an [`crate::webview::InvokeRequest`].
1902
1907
pub fn on_message (
1903
1908
self ,
You can’t perform that action at this time.
0 commit comments