Ver código fonte

Fix typo `WryProtocol`

Aster 3 anos atrás
pai
commit
aad055cd84
2 arquivos alterados com 11 adições e 5 exclusões
  1. 10 4
      packages/desktop/src/cfg.rs
  2. 1 1
      packages/desktop/src/lib.rs

+ 10 - 4
packages/desktop/src/cfg.rs

@@ -1,3 +1,4 @@
+use wry::application::window::Icon;
 use wry::{
 use wry::{
     application::{
     application::{
         event_loop::EventLoop,
         event_loop::EventLoop,
@@ -13,12 +14,12 @@ pub(crate) type DynEventHandlerFn = dyn Fn(&mut EventLoop<()>, &mut WebView);
 pub struct DesktopConfig {
 pub struct DesktopConfig {
     pub window: WindowBuilder,
     pub window: WindowBuilder,
     pub file_drop_handler: Option<Box<dyn Fn(&Window, FileDropEvent) -> bool>>,
     pub file_drop_handler: Option<Box<dyn Fn(&Window, FileDropEvent) -> bool>>,
-    pub protocos: Vec<WryProtocl>,
+    pub protocols: Vec<WryProtocol>,
     pub(crate) pre_rendered: Option<String>,
     pub(crate) pre_rendered: Option<String>,
     pub(crate) event_handler: Option<Box<DynEventHandlerFn>>,
     pub(crate) event_handler: Option<Box<DynEventHandlerFn>>,
 }
 }
 
 
-pub type WryProtocl = (
+pub type WryProtocol = (
     String,
     String,
     Box<dyn Fn(&HttpRequest) -> WryResult<HttpResponse> + 'static>,
     Box<dyn Fn(&HttpRequest) -> WryResult<HttpResponse> + 'static>,
 );
 );
@@ -31,7 +32,7 @@ impl DesktopConfig {
         Self {
         Self {
             event_handler: None,
             event_handler: None,
             window,
             window,
-            protocos: Vec::new(),
+            protocols: Vec::new(),
             file_drop_handler: None,
             file_drop_handler: None,
             pre_rendered: None,
             pre_rendered: None,
         }
         }
@@ -75,7 +76,12 @@ impl DesktopConfig {
     where
     where
         F: Fn(&HttpRequest) -> WryResult<HttpResponse> + 'static,
         F: Fn(&HttpRequest) -> WryResult<HttpResponse> + 'static,
     {
     {
-        self.protocos.push((name, Box::new(handler)));
+        self.protocols.push((name, Box::new(handler)));
+        self
+    }
+
+    pub fn with_icon(&mut self, icon: Icon) -> &mut Self {
+        self.window.window.window_icon = Some(icon);
         self
         self
     }
     }
 }
 }

+ 1 - 1
packages/desktop/src/lib.rs

@@ -261,7 +261,7 @@ pub fn launch_with_props<P: 'static + Send>(
                             .unwrap_or_default()
                             .unwrap_or_default()
                     });
                     });
 
 
-                for (name, handler) in cfg.protocos.drain(..) {
+                for (name, handler) in cfg.protocols.drain(..) {
                     webview = webview.with_custom_protocol(name, handler)
                     webview = webview.with_custom_protocol(name, handler)
                 }
                 }