mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-10-25 05:02:07 +08:00
fix: defer runtime config init until after window
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user