fix: defer runtime config init until after window

This commit is contained in:
Tunglies
2026-06-29 05:19:38 +08:00
parent 3a4cd2c361
commit 2a5d29cdb2
2 changed files with 22 additions and 3 deletions
+9
View File
@@ -63,6 +63,11 @@ impl Config {
/// 初始化订阅
pub async fn init_config() -> Result<()> {
Self::init_config_before_window().await?;
Self::init_runtime_config().await
}
pub async fn init_config_before_window() -> Result<()> {
Self::ensure_default_profile_items().await?;
let verge = Self::verge().await.latest_arc();
@@ -85,6 +90,10 @@ impl Config {
logging_error!(Type::Core, verge_data.save_file().await);
}
Ok(())
}
pub async fn init_runtime_config() -> Result<()> {
let validation_result = Self::generate_and_validate().await?;
if let Some((msg_type, msg_content)) = validation_result {
+13 -3
View File
@@ -53,9 +53,12 @@ pub fn resolve_setup_async() {
#[cfg(target_os = "macos")]
resolve_dock_show().await;
init_startup_script().await;
init_verge_config().await;
Config::verify_config_initialization().await;
let config_initialized = init_verge_config_before_window().await;
init_window().await;
if config_initialized {
init_verge_config().await;
}
Config::verify_config_initialization().await;
let core_init = AsyncHandler::spawn(|| async {
init_service_manager().await;
@@ -172,7 +175,14 @@ pub(super) async fn init_tray() {
}
pub(super) async fn init_verge_config() {
logging_error!(Type::Setup, Config::init_config().await);
logging_error!(Type::Setup, Config::init_runtime_config().await);
}
pub(super) async fn init_verge_config_before_window() -> bool {
let result = Config::init_config_before_window().await;
let success = result.is_ok();
logging_error!(Type::Setup, result);
success
}
pub(super) async fn init_service_manager() {