mirror of
https://github.com/farion1231/cc-switch.git
synced 2026-10-25 17:22:27 +08:00
fix(windows): show window after themed page loads
This commit is contained in:
1 parent
66269df739
commit
e0206ba8e2
2 files changed
+22
-1
No files matched your search
@@ -70,6 +70,8 @@ pub use store::AppState;
|
||||
use tauri_plugin_deep_link::DeepLinkExt;
|
||||
use tauri_plugin_dialog::{DialogExt, MessageDialogButtons, MessageDialogKind};
|
||||
|
||||
#[cfg(target_os = "windows")]
|
||||
use std::sync::atomic::{AtomicBool, Ordering};
|
||||
use std::{fmt, sync::Arc};
|
||||
#[cfg(target_os = "macos")]
|
||||
use tauri::image::Image;
|
||||
@@ -368,6 +370,22 @@ pub fn run() {
|
||||
}));
|
||||
}
|
||||
|
||||
#[cfg(target_os = "windows")]
|
||||
{
|
||||
let startup_page_handled = AtomicBool::new(false);
|
||||
builder = builder.on_page_load(move |webview, payload| {
|
||||
if webview.label() == "main"
|
||||
&& payload.event() == tauri::webview::PageLoadEvent::Finished
|
||||
&& payload.url().scheme() != "about"
|
||||
&& !startup_page_handled.swap(true, Ordering::Relaxed)
|
||||
&& !crate::settings::get_settings().silent_startup
|
||||
{
|
||||
let _ = webview.window().show();
|
||||
log::info!("主页面加载完成,主窗口已显示");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
let builder = builder
|
||||
// 注册 deep-link 插件(处理 macOS AppleEvent 和其他平台的深链接)
|
||||
.plugin(tauri_plugin_deep_link::init())
|
||||
@@ -1299,7 +1317,11 @@ pub fn run() {
|
||||
log::info!("静默启动模式:主窗口已隐藏");
|
||||
} else {
|
||||
// 正常启动模式:显示窗口
|
||||
#[cfg(not(target_os = "windows"))]
|
||||
let _ = window.show();
|
||||
#[cfg(target_os = "windows")]
|
||||
log::info!("正常启动模式:等待主页面加载完成后显示主窗口");
|
||||
#[cfg(not(target_os = "windows"))]
|
||||
log::info!("正常启动模式:主窗口已显示");
|
||||
|
||||
// Linux: 解决首次启动 UI 无响应问题(Tauri #10746 + wry #637)。
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
"minWidth": 900,
|
||||
"minHeight": 600,
|
||||
"visible": false,
|
||||
"backgroundColor": "#1e1e22",
|
||||
"resizable": true,
|
||||
"fullscreen": false,
|
||||
"center": true
|
||||
|
||||
Reference in new issue
Block a user