feat (desktop): upgrade from wry 37 to 41 (#2618)
This commit is contained in:
1 parent
b4934ab974
commit
69d7098d0e
6 files changed
+69
-53
No files matched your search
@@ -25,10 +25,10 @@ serde = "1.0.136"
|
||||
serde_json = "1.0.79"
|
||||
thiserror = { workspace = true }
|
||||
tracing = { workspace = true }
|
||||
wry = { version = "0.37.0", default-features = false, features = [
|
||||
wry = { version = "0.41.0", default-features = false, features = [
|
||||
"os-webview",
|
||||
"protocol",
|
||||
"file-drop",
|
||||
"drag-drop",
|
||||
] }
|
||||
futures-channel = { workspace = true }
|
||||
tokio = { workspace = true, features = [
|
||||
|
||||
@@ -300,8 +300,8 @@ impl App {
|
||||
if drag.files().is_some() {
|
||||
let file_event = recent_file.current().unwrap();
|
||||
let paths = match file_event {
|
||||
wry::FileDropEvent::Hovered { paths, .. } => paths,
|
||||
wry::FileDropEvent::Dropped { paths, .. } => paths,
|
||||
wry::DragDropEvent::Enter { paths, .. } => paths,
|
||||
wry::DragDropEvent::Drop { paths, .. } => paths,
|
||||
_ => vec![],
|
||||
};
|
||||
Rc::new(PlatformEventData::new(Box::new(DesktopFileDragEvent {
|
||||
|
||||
@@ -190,7 +190,9 @@ impl DesktopService {
|
||||
|
||||
/// Set the zoom level of the webview
|
||||
pub fn set_zoom_level(&self, level: f64) {
|
||||
self.webview.zoom(level);
|
||||
if let Err(e) = self.webview.zoom(level) {
|
||||
tracing::warn!("Set webview zoom failed: {e}");
|
||||
}
|
||||
}
|
||||
|
||||
/// opens DevTool window
|
||||
|
||||
@@ -19,7 +19,7 @@ use std::{
|
||||
str::FromStr,
|
||||
sync::Arc,
|
||||
};
|
||||
use wry::FileDropEvent;
|
||||
use wry::DragDropEvent;
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
pub(crate) struct FileDialogRequest {
|
||||
@@ -162,14 +162,14 @@ impl HasFormData for DesktopFileUploadForm {
|
||||
|
||||
#[derive(Default, Clone)]
|
||||
pub struct NativeFileHover {
|
||||
event: Rc<RefCell<Option<FileDropEvent>>>,
|
||||
event: Rc<RefCell<Option<DragDropEvent>>>,
|
||||
}
|
||||
impl NativeFileHover {
|
||||
pub fn set(&self, event: FileDropEvent) {
|
||||
pub fn set(&self, event: DragDropEvent) {
|
||||
self.event.borrow_mut().replace(event);
|
||||
}
|
||||
|
||||
pub fn current(&self) -> Option<FileDropEvent> {
|
||||
pub fn current(&self) -> Option<DragDropEvent> {
|
||||
self.event.borrow_mut().clone()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -106,9 +106,10 @@ impl WebviewInstance {
|
||||
}
|
||||
};
|
||||
|
||||
let ipc_handler = move |payload: String| {
|
||||
let ipc_handler = move |payload: wry::http::Request<String>| {
|
||||
// defer the event to the main thread
|
||||
if let Ok(msg) = serde_json::from_str(&payload) {
|
||||
let body = payload.into_body();
|
||||
if let Ok(msg) = serde_json::from_str(&body) {
|
||||
_ = proxy_.send_event(UserWindowEvent::Ipc { id: window_id, msg });
|
||||
}
|
||||
};
|
||||
@@ -159,7 +160,7 @@ impl WebviewInstance {
|
||||
}) // prevent all navigations
|
||||
.with_asynchronous_custom_protocol(String::from("dioxus"), request_handler)
|
||||
.with_web_context(&mut web_context)
|
||||
.with_file_drop_handler(file_drop_handler);
|
||||
.with_drag_drop_handler(file_drop_handler);
|
||||
|
||||
if let Some(color) = cfg.background_color {
|
||||
webview = webview.with_background_color(color);
|
||||
|
||||
Reference in new issue
Block a user