perf & fix: optimize window state initialization & add missing permissions

This commit is contained in:
wonfen
2025-05-16 09:50:53 +08:00
parent 53a46d0dc6
commit ddd85d4d87
3 changed files with 19 additions and 14 deletions

View File

@@ -17,6 +17,7 @@
"autostart:allow-enable", "autostart:allow-enable",
"autostart:allow-disable", "autostart:allow-disable",
"autostart:allow-is-enabled", "autostart:allow-is-enabled",
"core:window:allow-set-theme" "core:window:allow-set-theme",
"window-state:default"
] ]
} }

View File

@@ -137,12 +137,24 @@ pub fn run() {
.plugin(tauri_plugin_dialog::init()) .plugin(tauri_plugin_dialog::init())
.plugin(tauri_plugin_shell::init()) .plugin(tauri_plugin_shell::init())
.plugin(tauri_plugin_deep_link::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| { .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, "开始应用初始化..."); logging!(info, Type::Setup, true, "开始应用初始化...");
#[cfg(any(target_os = "linux", all(debug_assertions, windows)))] #[cfg(any(target_os = "linux", all(debug_assertions, windows)))]
{ {

View File

@@ -11,7 +11,6 @@ use anyhow::{bail, Result};
use once_cell::sync::OnceCell; use once_cell::sync::OnceCell;
use parking_lot::{Mutex, RwLock}; use parking_lot::{Mutex, RwLock};
use percent_encoding::percent_decode_str; use percent_encoding::percent_decode_str;
use serde::{Deserialize, Serialize};
use serde_yaml::Mapping; use serde_yaml::Mapping;
use std::{ use std::{
net::TcpListener, net::TcpListener,
@@ -65,13 +64,6 @@ impl Default for UiReadyState {
// 获取UI就绪状态细节 // 获取UI就绪状态细节
static UI_READY_STATE: OnceCell<Arc<UiReadyState>> = OnceCell::new(); static UI_READY_STATE: OnceCell<Arc<UiReadyState>> = OnceCell::new();
// 定义窗口状态结构体
#[derive(Debug, Serialize, Deserialize)]
struct WindowState {
width: Option<u32>,
height: Option<u32>,
}
fn get_window_creating_lock() -> &'static Mutex<(bool, Instant)> { fn get_window_creating_lock() -> &'static Mutex<(bool, Instant)> {
WINDOW_CREATING.get_or_init(|| Mutex::new((false, Instant::now()))) WINDOW_CREATING.get_or_init(|| Mutex::new((false, Instant::now())))
} }