修复iOS端WebView窗口命令空操作导致显示区域异常

This commit is contained in:
JSR
2026-03-19 19:02:03 +08:00
parent 0ef0112cd9
commit 24e7303040
+19 -25
View File
@@ -1,7 +1,6 @@
use parking_lot::RwLock;
use std::sync::Arc;
use tauri::AppHandle;
#[cfg(desktop)]
use tauri::Manager;
use crate::state::AppState;
@@ -28,12 +27,6 @@ pub async fn window_maximize(
app: AppHandle,
_state: tauri::State<'_, Arc<RwLock<AppState>>>,
) -> Result<bool, String> {
#[cfg(not(desktop))]
{
let _ = app;
return Ok(false);
}
#[cfg(desktop)]
{
if let Some(window) = app.get_webview_window("main") {
@@ -50,6 +43,16 @@ pub async fn window_maximize(
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]
@@ -74,12 +77,6 @@ pub async fn window_is_maximized(
app: AppHandle,
_state: tauri::State<'_, Arc<RwLock<AppState>>>,
) -> Result<bool, String> {
#[cfg(not(desktop))]
{
let _ = app;
return Ok(false);
}
#[cfg(desktop)]
{
if let Some(window) = app.get_webview_window("main") {
@@ -88,6 +85,15 @@ pub async fn window_is_maximized(
Ok(false)
}
}
#[cfg(not(desktop))]
{
if let Some(window) = app.get_webview_window("main") {
window.is_fullscreen().map_err(|e| e.to_string())
} else {
Ok(false)
}
}
}
#[tauri::command]
@@ -118,12 +124,6 @@ pub async fn window_resize(
app: AppHandle,
_state: tauri::State<'_, Arc<RwLock<AppState>>>,
) -> 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,12 +138,6 @@ pub async fn window_set_resizable(
app: AppHandle,
_state: tauri::State<'_, Arc<RwLock<AppState>>>,
) -> 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())?;
}