From 975c6d90843451629d9c26300d0c4b09fb3e7ca9 Mon Sep 17 00:00:00 2001 From: thepoy Date: Fri, 13 Dec 2024 12:36:58 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E4=B8=8D=E5=90=8C?= =?UTF-8?q?=E6=93=8D=E4=BD=9C=E7=B3=BB=E7=BB=9F=E4=B8=8B=E7=9A=84=E7=AA=97?= =?UTF-8?q?=E5=8F=A3=E5=88=9B=E5=BB=BA=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在 macOS 和 Windows 系统中,读取配置文件并根据 `transparent` 属性应用窗口效果。 - 在 Linux 系统中,简化窗口创建逻辑,不再读取 `transparent` 属性。 - 修复了在不同操作系统下窗口创建逻辑不一致的问题。 --- src-tauri/src/setup.rs | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/src-tauri/src/setup.rs b/src-tauri/src/setup.rs index 294a585..888dbd0 100644 --- a/src-tauri/src/setup.rs +++ b/src-tauri/src/setup.rs @@ -54,15 +54,18 @@ pub fn setup_app(app: &mut tauri::App) -> Result<(), Box> #[cfg(all(desktop, not(debug_assertions)))] setup_updater(app)?; - let config = Config::read_from_file()?; - - if cfg!(any(target_os = "macos", target_os = "windows")) { + #[cfg(any(target_os = "macos", target_os = "windows"))] + { + let config = Config::read_from_file()?; let window = create_main_window(app.app_handle(), config.transparent)?; if config.transparent { apply_window_effect(window)?; } - } else { - create_main_window(app.app_handle(), config.transparent)?; + } + + #[cfg(target_os = "linux")] + { + create_main_window(app.app_handle())?; } let eval_channel = EvalChannel { @@ -115,7 +118,7 @@ fn apply_window_effect(window: WebviewWindow) -> Result<(), Box Result> { trace!("Initializing main application window"); @@ -136,12 +139,17 @@ pub fn create_main_window( .title(WINDOW_TITLE) .resizable(false) .maximizable(false) - .transparent(transparent) .visible(false) .inner_size(WINDOW_WIDTH, WINDOW_HEIGHT); + #[cfg(any(target_os = "windows", target_os = "macos"))] + let window = window_builder.transparent(transparent).build(); + + #[cfg(target_os = "linux")] + let window = window_builder.build(); + // Attempt to build the window - match window_builder.build() { + match window { Ok(w) => { info!("Main application window created successfully"); Ok(w)