🐛 部分网站兼容有问题,先注释下
This commit is contained in:
@@ -12,9 +12,9 @@ use wry::{
|
|||||||
webview::WebViewBuilder,
|
webview::WebViewBuilder,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum UserEvent {
|
// enum UserEvent {
|
||||||
NewWindow(String),
|
// NewWindow(String),
|
||||||
}
|
// }
|
||||||
|
|
||||||
#[cfg(target_os = "macos")]
|
#[cfg(target_os = "macos")]
|
||||||
use wry::application::{
|
use wry::application::{
|
||||||
@@ -87,9 +87,9 @@ fn main() -> wry::Result<()> {
|
|||||||
..
|
..
|
||||||
} = get_windows_config().1.unwrap_or_default();
|
} = get_windows_config().1.unwrap_or_default();
|
||||||
|
|
||||||
let event_loop: EventLoop<UserEvent> = EventLoop::with_user_event();
|
// let event_loop: EventLoop<UserEvent> = EventLoop::with_user_event();
|
||||||
let proxy = event_loop.create_proxy();
|
// let proxy = event_loop.create_proxy();
|
||||||
|
let event_loop = EventLoop::new();
|
||||||
let common_window = WindowBuilder::new()
|
let common_window = WindowBuilder::new()
|
||||||
.with_title("")
|
.with_title("")
|
||||||
.with_resizable(resizable)
|
.with_resizable(resizable)
|
||||||
@@ -151,10 +151,10 @@ fn main() -> wry::Result<()> {
|
|||||||
.with_devtools(cfg!(feature = "devtools"))
|
.with_devtools(cfg!(feature = "devtools"))
|
||||||
.with_initialization_script(include_str!("pake.js"))
|
.with_initialization_script(include_str!("pake.js"))
|
||||||
.with_ipc_handler(handler)
|
.with_ipc_handler(handler)
|
||||||
.with_new_window_req_handler(move |uri: String| {
|
// .with_new_window_req_handler(move |uri: String| {
|
||||||
let submitted = proxy.send_event(UserEvent::NewWindow(uri.clone())).is_ok();
|
// let submitted = proxy.send_event(UserEvent::NewWindow(uri.clone())).is_ok();
|
||||||
submitted
|
// submitted
|
||||||
})
|
// })
|
||||||
.with_back_forward_navigation_gestures(true)
|
.with_back_forward_navigation_gestures(true)
|
||||||
.build()?
|
.build()?
|
||||||
};
|
};
|
||||||
@@ -185,10 +185,10 @@ fn main() -> wry::Result<()> {
|
|||||||
.with_initialization_script(include_str!("pake.js"))
|
.with_initialization_script(include_str!("pake.js"))
|
||||||
.with_ipc_handler(handler)
|
.with_ipc_handler(handler)
|
||||||
.with_web_context(&mut web_content)
|
.with_web_context(&mut web_content)
|
||||||
.with_new_window_req_handler(move |uri: String| {
|
// .with_new_window_req_handler(move |uri: String| {
|
||||||
let submitted = proxy.send_event(UserEvent::NewWindow(uri.clone())).is_ok();
|
// let submitted = proxy.send_event(UserEvent::NewWindow(uri.clone())).is_ok();
|
||||||
submitted
|
// submitted
|
||||||
})
|
// })
|
||||||
.build()?
|
.build()?
|
||||||
};
|
};
|
||||||
#[cfg(feature = "devtools")]
|
#[cfg(feature = "devtools")]
|
||||||
@@ -217,11 +217,9 @@ fn main() -> wry::Result<()> {
|
|||||||
println!("Clicked on {:?}", menu_id);
|
println!("Clicked on {:?}", menu_id);
|
||||||
println!("Clicked on {:?}", webview.window().is_visible());
|
println!("Clicked on {:?}", webview.window().is_visible());
|
||||||
}
|
}
|
||||||
Event::UserEvent(UserEvent::NewWindow(uri)) => {
|
// Event::UserEvent(UserEvent::NewWindow(uri)) => {
|
||||||
if &uri.to_string() != "about:blank" {
|
// webbrowser::open(&uri).expect("no browser");
|
||||||
webview.load_url(&uri);
|
// }
|
||||||
}
|
|
||||||
}
|
|
||||||
_ => (),
|
_ => (),
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user