mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-01-29 00:35:38 +08:00
feat: integrate window state management for improved window restoration and logging
This commit is contained in:
@@ -19,6 +19,7 @@ use tauri::AppHandle;
|
|||||||
use tauri::Manager;
|
use tauri::Manager;
|
||||||
use tauri_plugin_autostart::MacosLauncher;
|
use tauri_plugin_autostart::MacosLauncher;
|
||||||
use tauri_plugin_deep_link::DeepLinkExt;
|
use tauri_plugin_deep_link::DeepLinkExt;
|
||||||
|
use tauri_plugin_window_state::{StateFlags, WindowExt};
|
||||||
use tokio::time::{timeout, Duration};
|
use tokio::time::{timeout, Duration};
|
||||||
use utils::logging::Type;
|
use utils::logging::Type;
|
||||||
|
|
||||||
@@ -137,24 +138,13 @@ 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::new()
|
||||||
|
.with_state_flags(tauri_plugin_window_state::StateFlags::all())
|
||||||
|
.skip_initial_state("main")
|
||||||
|
.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)))]
|
||||||
{
|
{
|
||||||
@@ -342,6 +332,7 @@ pub fn run() {
|
|||||||
{
|
{
|
||||||
logging!(info, Type::Window, true, "设置macOS窗口标题");
|
logging!(info, Type::Window, true, "设置macOS窗口标题");
|
||||||
let _ = window.set_title("Clash Verge");
|
let _ = window.set_title("Clash Verge");
|
||||||
|
logging_error!(Type::Window, true, window.restore_state(StateFlags::all()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ use std::{
|
|||||||
time::{Duration, Instant},
|
time::{Duration, Instant},
|
||||||
};
|
};
|
||||||
use tauri::{AppHandle, Manager};
|
use tauri::{AppHandle, Manager};
|
||||||
|
use tauri_plugin_window_state::WindowExt;
|
||||||
use tokio::net::TcpListener;
|
use tokio::net::TcpListener;
|
||||||
|
|
||||||
use tauri::Url;
|
use tauri::Url;
|
||||||
@@ -373,6 +374,12 @@ pub fn create_window(is_show: bool) -> bool {
|
|||||||
*get_ui_ready().write() = true;
|
*get_ui_ready().write() = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
logging_error!(
|
||||||
|
Type::Window,
|
||||||
|
true,
|
||||||
|
newly_created_window
|
||||||
|
.restore_state(tauri_plugin_window_state::StateFlags::all())
|
||||||
|
);
|
||||||
logging!(info, Type::Window, true, "窗口显示流程完成");
|
logging!(info, Type::Window, true, "窗口显示流程完成");
|
||||||
} else {
|
} else {
|
||||||
logging!(
|
logging!(
|
||||||
|
|||||||
Reference in New Issue
Block a user