forked from didirus/AstralRinth
refactor(app): reduce tech debt by eliminating wry fork (#4500)
This commit is contained in:
committed by
GitHub
parent
7e682c22bb
commit
dbc64afe48
7
Cargo.lock
generated
7
Cargo.lock
generated
@@ -9328,6 +9328,8 @@ dependencies = [
|
|||||||
"url",
|
"url",
|
||||||
"urlencoding",
|
"urlencoding",
|
||||||
"uuid 1.18.1",
|
"uuid 1.18.1",
|
||||||
|
"webview2-com",
|
||||||
|
"windows-core 0.61.2",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -11677,8 +11679,3 @@ dependencies = [
|
|||||||
"wasm-bindgen",
|
"wasm-bindgen",
|
||||||
"web-sys",
|
"web-sys",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[patch.unused]]
|
|
||||||
name = "wry"
|
|
||||||
version = "0.52.1"
|
|
||||||
source = "git+https://github.com/modrinth/wry?rev=f2ce0b0#f2ce0b0105d9d94f482c4f8ecffb4f3c3c325b40"
|
|
||||||
|
|||||||
@@ -182,6 +182,7 @@ webp = { version = "0.3.0", default-features = false }
|
|||||||
whoami = "1.6.0"
|
whoami = "1.6.0"
|
||||||
windows = "0.61.3"
|
windows = "0.61.3"
|
||||||
windows-core = "0.61.2"
|
windows-core = "0.61.2"
|
||||||
|
webview2-com = "0.38.0" # Should be updated in lockstep with wry
|
||||||
winreg = "0.55.0"
|
winreg = "0.55.0"
|
||||||
woothee = "0.13.0"
|
woothee = "0.13.0"
|
||||||
yaserde = "0.12.0"
|
yaserde = "0.12.0"
|
||||||
@@ -228,9 +229,6 @@ todo = "warn"
|
|||||||
unnested_or_patterns = "warn"
|
unnested_or_patterns = "warn"
|
||||||
wildcard_dependencies = "warn"
|
wildcard_dependencies = "warn"
|
||||||
|
|
||||||
[patch.crates-io]
|
|
||||||
wry = { git = "https://github.com/modrinth/wry", rev = "f2ce0b0" }
|
|
||||||
|
|
||||||
# Optimize for speed and reduce size on release builds
|
# Optimize for speed and reduce size on release builds
|
||||||
[profile.release]
|
[profile.release]
|
||||||
opt-level = "s" # Optimize for binary size
|
opt-level = "s" # Optimize for binary size
|
||||||
|
|||||||
@@ -51,6 +51,10 @@ native-dialog.workspace = true
|
|||||||
[target.'cfg(target_os = "linux")'.dependencies]
|
[target.'cfg(target_os = "linux")'.dependencies]
|
||||||
tauri-plugin-updater = { workspace = true, optional = true }
|
tauri-plugin-updater = { workspace = true, optional = true }
|
||||||
|
|
||||||
|
[target.'cfg(windows)'.dependencies]
|
||||||
|
webview2-com.workspace = true
|
||||||
|
windows-core.workspace = true
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
# by default Tauri runs in production mode
|
# by default Tauri runs in production mode
|
||||||
# when `tauri dev` runs it is executed with `cargo run --no-default-features` if `devPath` is an URL
|
# when `tauri dev` runs it is executed with `cargo run --no-default-features` if `devPath` is an URL
|
||||||
|
|||||||
@@ -79,7 +79,6 @@ pub async fn init_ads_window<R: Runtime>(
|
|||||||
override_shown: bool,
|
override_shown: bool,
|
||||||
) -> crate::api::Result<()> {
|
) -> crate::api::Result<()> {
|
||||||
use tauri::WebviewUrl;
|
use tauri::WebviewUrl;
|
||||||
const LINK_SCRIPT: &str = include_str!("ads-init.js");
|
|
||||||
|
|
||||||
let state = app.state::<RwLock<AdsState>>();
|
let state = app.state::<RwLock<AdsState>>();
|
||||||
let mut state = state.write().await;
|
let mut state = state.write().await;
|
||||||
@@ -102,25 +101,42 @@ pub async fn init_ads_window<R: Runtime>(
|
|||||||
webview.set_position(PhysicalPosition::new(-1000, -1000));
|
webview.set_position(PhysicalPosition::new(-1000, -1000));
|
||||||
}
|
}
|
||||||
} else if let Some(window) = app.get_window("main") {
|
} else if let Some(window) = app.get_window("main") {
|
||||||
let _ = window.add_child(
|
let webview = window.add_child(
|
||||||
tauri::webview::WebviewBuilder::new(
|
tauri::webview::WebviewBuilder::new(
|
||||||
"ads-window",
|
"ads-window",
|
||||||
WebviewUrl::External(
|
WebviewUrl::External(
|
||||||
AD_LINK.parse().unwrap(),
|
AD_LINK.parse().unwrap(),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
.initialization_script(LINK_SCRIPT)
|
.initialization_script_for_all_frames(include_str!("ads-init.js"))
|
||||||
// .initialization_script_for_main_only(LINK_SCRIPT, false)
|
.user_agent("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36")
|
||||||
.user_agent("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36")
|
.zoom_hotkeys_enabled(false)
|
||||||
.zoom_hotkeys_enabled(false)
|
.transparent(true)
|
||||||
.transparent(true),
|
.on_new_window(|_, _| tauri::webview::NewWindowResponse::Deny),
|
||||||
if state.shown {
|
if state.shown {
|
||||||
position
|
position
|
||||||
} else {
|
} else {
|
||||||
PhysicalPosition::new(-1000.0, -1000.0)
|
PhysicalPosition::new(-1000.0, -1000.0)
|
||||||
},
|
},
|
||||||
size,
|
size,
|
||||||
);
|
)?;
|
||||||
|
|
||||||
|
webview.with_webview(#[allow(unused_variables)] |webview2| {
|
||||||
|
#[cfg(windows)]
|
||||||
|
{
|
||||||
|
use webview2_com::Microsoft::Web::WebView2::Win32::ICoreWebView2_8;
|
||||||
|
use windows_core::Interface;
|
||||||
|
|
||||||
|
let webview2_controller = webview2.controller();
|
||||||
|
let Ok(webview2_8) = unsafe { webview2_controller.CoreWebView2() }
|
||||||
|
.and_then(|core_webview2| core_webview2.cast::<ICoreWebView2_8>())
|
||||||
|
else {
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
|
||||||
|
unsafe { webview2_8.SetIsMuted(true) }.ok();
|
||||||
|
}
|
||||||
|
})?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user