From c4c65861c9277eed4f3e76ae84bbd1771b66a752 Mon Sep 17 00:00:00 2001 From: JSR Date: Thu, 19 Mar 2026 19:08:33 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8DiOS=E6=9E=84=E5=BB=BA?= =?UTF-8?q?=E5=A4=B1=E8=B4=A5=E5=B9=B6=E8=B0=83=E6=95=B4=E5=88=9D=E5=A7=8B?= =?UTF-8?q?=E7=AA=97=E5=8F=A3=E5=B0=BA=E5=AF=B8=E4=BB=A5=E9=81=BF=E5=85=8D?= =?UTF-8?q?=E5=BA=95=E9=83=A8=E9=BB=91=E8=BE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src-tauri/src/commands/window.rs | 62 +++++++++++++++++--------------- src-tauri/src/lib.rs | 6 ++++ src-tauri/tauri.conf.json | 4 +-- 3 files changed, 42 insertions(+), 30 deletions(-) diff --git a/src-tauri/src/commands/window.rs b/src-tauri/src/commands/window.rs index 00fd06d..843e6fa 100644 --- a/src-tauri/src/commands/window.rs +++ b/src-tauri/src/commands/window.rs @@ -1,6 +1,7 @@ use parking_lot::RwLock; use std::sync::Arc; use tauri::AppHandle; +#[cfg(desktop)] use tauri::Manager; use crate::state::AppState; @@ -27,32 +28,28 @@ pub async fn window_maximize( app: AppHandle, _state: tauri::State<'_, Arc>>, ) -> Result { + #[cfg(not(desktop))] + { + let _ = app; + return Ok(false); + } + #[cfg(desktop)] { if let Some(window) = app.get_webview_window("main") { - let is_maximized = window.is_maximized().map_err(|e| e.to_string())?; + let is_maximized = window.is_maximized().map_err(|e| e.to_string())?; - if is_maximized { - window.unmaximize().map_err(|e| e.to_string())?; - Ok(false) - } else { - window.maximize().map_err(|e| e.to_string())?; - Ok(true) - } + if is_maximized { + window.unmaximize().map_err(|e| e.to_string())?; + Ok(false) + } else { + window.maximize().map_err(|e| e.to_string())?; + Ok(true) + } } else { Err("Window not found".to_string()) } } - - #[cfg(not(desktop))] - { - if let Some(window) = app.get_webview_window("main") { - window.set_fullscreen(true).map_err(|e| e.to_string())?; - Ok(true) - } else { - Ok(false) - } - } } #[tauri::command] @@ -77,19 +74,16 @@ pub async fn window_is_maximized( app: AppHandle, _state: tauri::State<'_, Arc>>, ) -> Result { + #[cfg(not(desktop))] + { + let _ = app; + return Ok(false); + } + #[cfg(desktop)] { if let Some(window) = app.get_webview_window("main") { - window.is_maximized().map_err(|e| e.to_string()) - } else { - Ok(false) - } - } - - #[cfg(not(desktop))] - { - if let Some(window) = app.get_webview_window("main") { - window.is_fullscreen().map_err(|e| e.to_string()) + window.is_maximized().map_err(|e| e.to_string()) } else { Ok(false) } @@ -124,6 +118,12 @@ pub async fn window_resize( app: AppHandle, _state: tauri::State<'_, Arc>>, ) -> Result<(), String> { + #[cfg(not(desktop))] + { + let _ = (width, height, app); + } + + #[cfg(desktop)] if let Some(window) = app.get_webview_window("main") { window .set_size(tauri::Size::Physical(tauri::PhysicalSize { width, height })) @@ -138,6 +138,12 @@ pub async fn window_set_resizable( app: AppHandle, _state: tauri::State<'_, Arc>>, ) -> Result<(), String> { + #[cfg(not(desktop))] + { + let _ = (resizable, app); + } + + #[cfg(desktop)] if let Some(window) = app.get_webview_window("main") { window.set_resizable(resizable).map_err(|e| e.to_string())?; } diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index 96272a9..944630d 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -298,6 +298,12 @@ fn setup_tray(_app: &mut App) -> Result<(), Box> { #[cfg(desktop)] fn setup_window_events(app: &mut App) -> Result<(), Box> { if let Some(window) = app.get_webview_window("main") { + let _ = window.set_size(tauri::Size::Physical(tauri::PhysicalSize { + width: 1180, + height: 680, + })); + let _ = window.center(); + #[cfg(target_os = "macos")] { let _ = window.set_shadow(true); diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index 8ca26ee..bc9e2ff 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -15,8 +15,8 @@ "windows": [ { "title": "SecScore", - "width": 1180, - "height": 680, + "width": 10000, + "height": 10000, "resizable": true, "fullscreen": false, "decorations": false,