修复iOS构建失败并调整初始窗口尺寸以避免底部黑边

This commit is contained in:
JSR
2026-03-19 19:08:33 +08:00
parent 24e7303040
commit c4c65861c9
3 changed files with 42 additions and 30 deletions
+25 -19
View File
@@ -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,6 +28,12 @@ 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") {
@@ -43,16 +50,6 @@ 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]
@@ -77,6 +74,12 @@ 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") {
@@ -85,15 +88,6 @@ 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]
@@ -124,6 +118,12 @@ 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,6 +138,12 @@ 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())?;
}
+6
View File
@@ -298,6 +298,12 @@ fn setup_tray(_app: &mut App) -> Result<(), Box<dyn std::error::Error>> {
#[cfg(desktop)]
fn setup_window_events(app: &mut App) -> Result<(), Box<dyn std::error::Error>> {
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);
+2 -2
View File
@@ -15,8 +15,8 @@
"windows": [
{
"title": "SecScore",
"width": 1180,
"height": 680,
"width": 10000,
"height": 10000,
"resizable": true,
"fullscreen": false,
"decorations": false,