fix: window transparent and can not get hwnd

This commit is contained in:
GyDi 2022-05-25 19:06:06 +08:00
parent ae94993b09
commit 98b8bd90ea
No known key found for this signature in database
GPG Key ID: 1C95E0D3467B3084

View File

@ -1,4 +1,4 @@
use crate::{core::Core, log_if_err, utils::init, utils::server}; use crate::{core::Core, utils::init, utils::server};
use tauri::{App, AppHandle, Manager}; use tauri::{App, AppHandle, Manager};
/// handle something when start app /// handle something when start app
@ -79,6 +79,7 @@ pub fn create_window(app_handle: &AppHandle) {
.title("Clash Verge") .title("Clash Verge")
.center() .center()
.fullscreen(false) .fullscreen(false)
.transparent(true)
.min_inner_size(600.0, 520.0); .min_inner_size(600.0, 520.0);
#[cfg(target_os = "windows")] #[cfg(target_os = "windows")]
@ -88,20 +89,26 @@ pub fn create_window(app_handle: &AppHandle) {
use window_vibrancy::apply_blur; use window_vibrancy::apply_blur;
match builder.decorations(false).inner_size(800.0, 636.0).build() { match builder.decorations(false).inner_size(800.0, 636.0).build() {
Ok(window) => { Ok(_) => {
let _ = set_shadow(&window, true); let app_handle = app_handle.clone();
if !winhelp::is_win11() { tauri::async_runtime::spawn(async move {
let _ = apply_blur(&window, None); if let Some(window) = app_handle.get_window("main") {
} let _ = set_shadow(&window, true);
if !winhelp::is_win11() {
let _ = apply_blur(&window, None);
}
}
});
} }
Err(err) => log::error!("{err}"), Err(err) => log::error!("{err}"),
} }
} }
#[cfg(target_os = "macos")] #[cfg(target_os = "macos")]
log_if_err!(builder.decorations(true).inner_size(800.0, 620.0).build()); crate::log_if_err!(builder.decorations(true).inner_size(800.0, 620.0).build());
#[cfg(target_os = "linux")] #[cfg(target_os = "linux")]
log_if_err!(builder.decorations(false).inner_size(800.0, 636.0).build()); crate::log_if_err!(builder.decorations(false).inner_size(800.0, 636.0).build());
} }