diff --git a/src-tauri/capabilities/desktop.json b/src-tauri/capabilities/desktop.json index 823c9af9..e525e29f 100755 --- a/src-tauri/capabilities/desktop.json +++ b/src-tauri/capabilities/desktop.json @@ -17,6 +17,7 @@ "autostart:allow-enable", "autostart:allow-disable", "autostart:allow-is-enabled", - "core:window:allow-set-theme" + "core:window:allow-set-theme", + "window-state:default" ] } diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index 0cffd99d..32f7266e 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -137,12 +137,24 @@ pub fn run() { .plugin(tauri_plugin_dialog::init()) .plugin(tauri_plugin_shell::init()) .plugin(tauri_plugin_deep_link::init()) - .plugin( - tauri_plugin_window_state::Builder::default() - .with_state_flags(tauri_plugin_window_state::StateFlags::all()) - .build(), - ) .setup(|app| { + #[cfg(desktop)] + { + if let Err(e) = app.handle().plugin( + tauri_plugin_window_state::Builder::default() + .with_state_flags(tauri_plugin_window_state::StateFlags::all()) + .build(), + ) { + logging!( + error, + Type::Setup, + true, + "Failed to initialize tauri-plugin-window-state: {}", + e + ); + } + } + logging!(info, Type::Setup, true, "开始应用初始化..."); #[cfg(any(target_os = "linux", all(debug_assertions, windows)))] { diff --git a/src-tauri/src/utils/resolve.rs b/src-tauri/src/utils/resolve.rs index 45d36eff..8b182657 100644 --- a/src-tauri/src/utils/resolve.rs +++ b/src-tauri/src/utils/resolve.rs @@ -11,7 +11,6 @@ use anyhow::{bail, Result}; use once_cell::sync::OnceCell; use parking_lot::{Mutex, RwLock}; use percent_encoding::percent_decode_str; -use serde::{Deserialize, Serialize}; use serde_yaml::Mapping; use std::{ net::TcpListener, @@ -65,13 +64,6 @@ impl Default for UiReadyState { // 获取UI就绪状态细节 static UI_READY_STATE: OnceCell> = OnceCell::new(); -// 定义窗口状态结构体 -#[derive(Debug, Serialize, Deserialize)] -struct WindowState { - width: Option, - height: Option, -} - fn get_window_creating_lock() -> &'static Mutex<(bool, Instant)> { WINDOW_CREATING.get_or_init(|| Mutex::new((false, Instant::now()))) }