perf & fix: optimize window state initialization & add missing permissions
This commit is contained in:
@@ -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"
|
||||
]
|
||||
}
|
||||
|
||||
@@ -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)))]
|
||||
{
|
||||
|
||||
@@ -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<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)> {
|
||||
WINDOW_CREATING.get_or_init(|| Mutex::new((false, Instant::now())))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user