mirror of
https://github.com/SECTL/SecScore.git
synced 2026-07-19 19:04:23 +08:00
修复iOS端WebView窗口命令空操作导致显示区域异常
This commit is contained in:
@@ -1,7 +1,6 @@
|
|||||||
use parking_lot::RwLock;
|
use parking_lot::RwLock;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use tauri::AppHandle;
|
use tauri::AppHandle;
|
||||||
#[cfg(desktop)]
|
|
||||||
use tauri::Manager;
|
use tauri::Manager;
|
||||||
|
|
||||||
use crate::state::AppState;
|
use crate::state::AppState;
|
||||||
@@ -28,28 +27,32 @@ pub async fn window_maximize(
|
|||||||
app: AppHandle,
|
app: AppHandle,
|
||||||
_state: tauri::State<'_, Arc<RwLock<AppState>>>,
|
_state: tauri::State<'_, Arc<RwLock<AppState>>>,
|
||||||
) -> Result<bool, String> {
|
) -> Result<bool, String> {
|
||||||
#[cfg(not(desktop))]
|
|
||||||
{
|
|
||||||
let _ = app;
|
|
||||||
return Ok(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(desktop)]
|
#[cfg(desktop)]
|
||||||
{
|
{
|
||||||
if let Some(window) = app.get_webview_window("main") {
|
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 {
|
if is_maximized {
|
||||||
window.unmaximize().map_err(|e| e.to_string())?;
|
window.unmaximize().map_err(|e| e.to_string())?;
|
||||||
Ok(false)
|
Ok(false)
|
||||||
} else {
|
} else {
|
||||||
window.maximize().map_err(|e| e.to_string())?;
|
window.maximize().map_err(|e| e.to_string())?;
|
||||||
Ok(true)
|
Ok(true)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Err("Window not found".to_string())
|
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]
|
#[tauri::command]
|
||||||
@@ -74,16 +77,19 @@ pub async fn window_is_maximized(
|
|||||||
app: AppHandle,
|
app: AppHandle,
|
||||||
_state: tauri::State<'_, Arc<RwLock<AppState>>>,
|
_state: tauri::State<'_, Arc<RwLock<AppState>>>,
|
||||||
) -> Result<bool, String> {
|
) -> Result<bool, String> {
|
||||||
#[cfg(not(desktop))]
|
|
||||||
{
|
|
||||||
let _ = app;
|
|
||||||
return Ok(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(desktop)]
|
#[cfg(desktop)]
|
||||||
{
|
{
|
||||||
if let Some(window) = app.get_webview_window("main") {
|
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 {
|
} else {
|
||||||
Ok(false)
|
Ok(false)
|
||||||
}
|
}
|
||||||
@@ -118,12 +124,6 @@ pub async fn window_resize(
|
|||||||
app: AppHandle,
|
app: AppHandle,
|
||||||
_state: tauri::State<'_, Arc<RwLock<AppState>>>,
|
_state: tauri::State<'_, Arc<RwLock<AppState>>>,
|
||||||
) -> Result<(), String> {
|
) -> Result<(), String> {
|
||||||
#[cfg(not(desktop))]
|
|
||||||
{
|
|
||||||
let _ = (width, height, app);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(desktop)]
|
|
||||||
if let Some(window) = app.get_webview_window("main") {
|
if let Some(window) = app.get_webview_window("main") {
|
||||||
window
|
window
|
||||||
.set_size(tauri::Size::Physical(tauri::PhysicalSize { width, height }))
|
.set_size(tauri::Size::Physical(tauri::PhysicalSize { width, height }))
|
||||||
@@ -138,12 +138,6 @@ pub async fn window_set_resizable(
|
|||||||
app: AppHandle,
|
app: AppHandle,
|
||||||
_state: tauri::State<'_, Arc<RwLock<AppState>>>,
|
_state: tauri::State<'_, Arc<RwLock<AppState>>>,
|
||||||
) -> Result<(), String> {
|
) -> Result<(), String> {
|
||||||
#[cfg(not(desktop))]
|
|
||||||
{
|
|
||||||
let _ = (resizable, app);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(desktop)]
|
|
||||||
if let Some(window) = app.get_webview_window("main") {
|
if let Some(window) = app.get_webview_window("main") {
|
||||||
window.set_resizable(resizable).map_err(|e| e.to_string())?;
|
window.set_resizable(resizable).map_err(|e| e.to_string())?;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user