mirror of
https://github.com/SECTL/SecScore.git
synced 2026-07-19 21:14:21 +08:00
修复iOS端WebView窗口命令空操作导致显示区域异常
This commit is contained in:
@@ -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,28 +27,32 @@ 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") {
|
||||
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]
|
||||
@@ -74,16 +77,19 @@ 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") {
|
||||
window.is_maximized().map_err(|e| e.to_string())
|
||||
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())
|
||||
} else {
|
||||
Ok(false)
|
||||
}
|
||||
@@ -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())?;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user