Skip to content

Commit

Permalink
fix: use webview2-com-bridge to solve ra crash issue
Browse files Browse the repository at this point in the history
  • Loading branch information
greenhat616 committed May 13, 2024
1 parent 9678d20 commit d583276
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 9 deletions.
11 changes: 9 additions & 2 deletions backend/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion backend/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[workspace]
resolver = "2"
members = ["tauri", "sysproxy-rs"]
members = ["tauri", "sysproxy-rs", "webview2-com-bridge"]

[workspace.package]
repository = "https://github.com/keiko233/clash-nyanpasu.git"
Expand Down
3 changes: 1 addition & 2 deletions backend/tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,7 @@ windows-sys = { version = "0.52", features = [
"Win32_System_LibraryLoader",
"Win32_System_SystemInformation",
] }
webview2-com = "0.19"
windows = "0.39"
webview2-com-bridge = { path = "../webview2-com-bridge" }

[target.'cfg(windows)'.dependencies.tauri]
version = "1.5.4"
Expand Down
7 changes: 3 additions & 4 deletions backend/tauri/src/utils/resolve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,8 @@ use semver::Version;
use serde_yaml::Mapping;
use std::net::TcpListener;
use tauri::{api::process::Command, App, AppHandle, Manager, PhysicalPosition, PhysicalSize};

#[cfg(target_os = "windows")]
use webview2_com::Microsoft::Web::WebView2::Win32::ICoreWebView2Settings6;
#[cfg(target_os = "windows")]
use windows::core::Interface;
use webview2_com_bridge::windows::core::Interface;

pub fn find_unused_port() -> Result<u16> {
match TcpListener::bind("127.0.0.1:0") {
Expand Down Expand Up @@ -274,6 +271,8 @@ pub fn create_window(app_handle: &AppHandle) {
.get_window("main")
.unwrap()
.with_webview(|webview| unsafe {
#[cfg(target_os = "windows")]
use webview2_com_bridge::webview2_com::Microsoft::Web::WebView2::Win32::ICoreWebView2Settings6;
let settings = webview
.controller()
.CoreWebView2()
Expand Down
11 changes: 11 additions & 0 deletions backend/webview2-com-bridge/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[package]
name = "webview2-com-bridge"
version = "0.1.0"
repository.workspace = true
edition.workspace = true
license.workspace = true
authors.workspace = true

[dependencies]
webview2-com = "0.19"
windows = "0.39"
2 changes: 2 additions & 0 deletions backend/webview2-com-bridge/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
pub use webview2_com;
pub use windows;

0 comments on commit d583276

Please sign in to comment.