From d3de87a3e0171de53ea5ebc60b37d0d8d7b03495 Mon Sep 17 00:00:00 2001 From: m1911star Date: Wed, 9 Nov 2022 17:09:48 +0800 Subject: [PATCH] fix: fix code review comments --- src-tauri/src/main.rs | 33 +++++++++++++-------------------- 1 file changed, 13 insertions(+), 20 deletions(-) diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index c5c6edc..b50da05 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -1,12 +1,12 @@ use tauri_utils::config::{Config, WindowConfig}; -#[cfg(macos)] +#[cfg(target_os = "macos")] use wry::{ application::{ platform::macos::WindowBuilderExtMacOS, } }; -#[cfg(windows)] +#[cfg(target_os = "windows")] use wry::{ application::{ platform::windows::WindowBuilderExtWindows @@ -59,19 +59,20 @@ fn main() -> wry::Result<()> { } = get_windows_config().unwrap_or(WindowConfig::default()); let event_loop = EventLoop::new(); + let common_window = WindowBuilder::new() + .with_resizable(resizable) + .with_transparent(transparent) + .with_fullscreen(if fullscreen { + Some(Fullscreen::Borderless(None)) + } else { + None + }) + .with_inner_size(wry::application::dpi::LogicalSize::new(width, height)); #[cfg(windows)] let init_window = || { - let window = WindowBuilder::new() - .with_resizable(resizable) - .with_transparent(transparent) - .with_fullscreen(if fullscreen { - Some(Fullscreen::Borderless(None)) - } else { - None - }) + let window = common_window .with_decorations(false) .with_title("") - .with_inner_size(wry::application::dpi::LogicalSize::new(width, height)) .build(&event_loop) .unwrap(); window @@ -79,19 +80,11 @@ fn main() -> wry::Result<()> { #[cfg(macos)] let init_window = || { - let window = WindowBuilder::new() - .with_resizable(resizable) - .with_titlebar_transparent(transparent) - .with_fullscreen(if fullscreen { - Some(Fullscreen::Borderless(None)) - } else { - None - }) + let window = common_window .with_fullsize_content_view(true) .with_titlebar_buttons_hidden(false) .with_title_hidden(true) .with_menu(menu_bar_menu) - .with_inner_size(wry::application::dpi::LogicalSize::new(width, height)) .build(&event_loop) .unwrap(); window