🐛 修复macOS平台的窗口大小适配逻辑

This commit is contained in:
BTMuli
2025-05-09 23:11:06 +08:00
parent 652a92a0da
commit 16332793ef
3 changed files with 22 additions and 12 deletions

View File

@@ -1,6 +1,6 @@
//! @file src/client/utils.rs
//! @desc 结合屏幕分辨率获取窗口大小
//! @since Beta v0.5.5
//! @since Beta v0.7.6
use tauri::{AppHandle, Manager, Monitor};
@@ -17,7 +17,15 @@ pub fn get_window_size2(monitor: Monitor, width: f64, height: f64) -> (f64, 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 / monitor_scale).round();
let get_height = (height * height_scale / monitor_scale).round();
let mut get_width: f64 = 0.0;
let mut get_height: f64 = 0.0;
dbg!(get_width, get_height); // 防止never read
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)
}