feat: manage windows with tauri window-state to address various window issues

This commit is contained in:
wonfen
2025-04-15 22:10:57 +08:00
committed by Tunglies
parent 18d24d5952
commit fad73a281a
6 changed files with 38 additions and 10 deletions

View File

@@ -20,6 +20,7 @@ use tauri::Manager;
use tauri_plugin_autostart::MacosLauncher;
use tauri_plugin_deep_link::DeepLinkExt;
use utils::logging::Type;
use tauri_plugin_window_state;
/// A global singleton handle to the application.
pub struct AppHandleManager {
@@ -117,6 +118,9 @@ 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(any(target_os = "linux", all(debug_assertions, windows)))]
{

View File

@@ -163,13 +163,14 @@ pub fn create_window(is_showup: bool) {
tauri::WebviewUrl::App("index.html".into()),
)
.title("Clash Verge")
.inner_size(890.0, 700.0)
.min_inner_size(620.0, 550.0)
.inner_size(900.0, 700.0)
.min_inner_size(650.0, 580.0)
.decorations(false)
.maximizable(true)
.additional_browser_args("--enable-features=msWebView2EnableDraggableRegions --disable-features=OverscrollHistoryNavigation,msExperimentalScrolling")
.transparent(true)
.shadow(true)
.visible(true)
.build();
#[cfg(target_os = "macos")]
@@ -181,8 +182,9 @@ pub fn create_window(is_showup: bool) {
.decorations(true)
.hidden_title(true)
.title_bar_style(tauri::TitleBarStyle::Overlay)
.inner_size(890.0, 700.0)
.min_inner_size(620.0, 550.0)
.inner_size(900.0, 700.0)
.min_inner_size(650.0, 580.0)
.visible(true)
.build();
#[cfg(target_os = "linux")]
@@ -193,17 +195,15 @@ pub fn create_window(is_showup: bool) {
)
.title("Clash Verge")
.decorations(false)
.inner_size(890.0, 700.0)
.min_inner_size(620.0, 550.0)
.inner_size(900.0, 700.0)
.min_inner_size(650.0, 580.0)
.transparent(true)
.visible(true)
.build();
match window {
Ok(window) => {
Ok(_) => {
logging!(info, Type::Window, true, "Window created successfully");
let _ = window.show();
let _ = window.set_focus();
// 标记前端UI已准备就绪向前端发送启动完成事件
let app_handle_clone = app_handle.clone();
AsyncHandler::spawn(move || async move {