diff --git a/src-tauri/src/client/utils.rs b/src-tauri/src/client/utils.rs index bf8c8d3d..e5108e46 100644 --- a/src-tauri/src/client/utils.rs +++ b/src-tauri/src/client/utils.rs @@ -1,6 +1,6 @@ //! @file src/client/utils.rs //! @desc 结合屏幕分辨率获取窗口大小 -//! @since Beta v0.7.9 +//! @since Beta v0.7.6 use tauri::{AppHandle, Manager, Monitor}; @@ -14,9 +14,19 @@ pub fn get_window_size2(monitor: Monitor, width: f64, height: f64) -> (f64, f64) let monitor_size = monitor.size(); let monitor_width = monitor_size.width as f64; let monitor_height = monitor_size.height as f64; + let monitor_scale = monitor.scale_factor(); let width_scale = monitor_width / 1920.0; let height_scale = monitor_height / 1080.0; - let get_width = (width * width_scale).round(); - let get_height = (height * height_scale).round(); + let mut get_width: f64 = 0.0; + let mut get_height: f64 = 0.0; + // 忽略未使用 + println!("{} {}", get_width, get_height); + get_width = (width * width_scale / monitor_scale).round(); + get_height = (height * height_scale / monitor_scale).round(); + #[cfg(target_os = "macos")] + { + get_width = (width * width_scale).round(); + get_height = (height * height_scale).round(); + } (get_width, get_height) }