fix: init work config and resources twice

This commit is contained in:
oomeow
2025-12-13 15:21:22 +08:00
parent 3c1bcd7d72
commit 5c42658a2e
2 changed files with 18 additions and 18 deletions

View File

@@ -10,8 +10,7 @@ mod feat;
mod module; mod module;
mod process; mod process;
pub mod utils; pub mod utils;
use crate::utils::resolve::init_signal; use crate::constants::files;
use crate::{constants::files, utils::resolve::prioritize_initialization};
use crate::{ use crate::{
core::handle, core::handle,
process::AsyncHandler, process::AsyncHandler,
@@ -237,7 +236,7 @@ pub fn run() {
.set(app.app_handle().clone()) .set(app.app_handle().clone())
.expect("failed to set global app handle"); .expect("failed to set global app handle");
let _handle = AsyncHandler::block_on(async { prioritize_initialization().await }); let _handle = resolve::init_work_dir_and_logger();
logging!(info, Type::Setup, "开始应用初始化..."); logging!(info, Type::Setup, "开始应用初始化...");
if let Err(e) = app_init::setup_autostart(app) { if let Err(e) = app_init::setup_autostart(app) {
@@ -253,7 +252,7 @@ pub fn run() {
resolve::resolve_setup_handle(); resolve::resolve_setup_handle();
resolve::resolve_setup_async(); resolve::resolve_setup_async();
resolve::resolve_setup_sync(); resolve::resolve_setup_sync();
init_signal(); resolve::init_signal();
resolve::resolve_done(); resolve::resolve_done();
logging!(info, Type::Setup, "初始化已启动"); logging!(info, Type::Setup, "初始化已启动");

View File

@@ -28,7 +28,8 @@ pub mod window_script;
static RESOLVE_DONE: AtomicBool = AtomicBool::new(false); static RESOLVE_DONE: AtomicBool = AtomicBool::new(false);
pub async fn prioritize_initialization() -> Option<LoggerHandle> { pub fn init_work_dir_and_logger() -> Option<LoggerHandle> {
AsyncHandler::block_on(async {
init_work_config().await; init_work_config().await;
init_resources().await; init_resources().await;
@@ -41,6 +42,7 @@ pub async fn prioritize_initialization() -> Option<LoggerHandle> {
{ {
None None
} }
})
} }
pub fn resolve_setup_handle() { pub fn resolve_setup_handle() {
@@ -58,8 +60,7 @@ pub fn resolve_setup_async() {
AsyncHandler::spawn(|| async { AsyncHandler::spawn(|| async {
logging!(info, Type::ClashVergeRev, "Version: {}", env!("CARGO_PKG_VERSION")); logging!(info, Type::ClashVergeRev, "Version: {}", env!("CARGO_PKG_VERSION"));
futures::join!(init_work_config(), init_resources(), init_startup_script()); init_startup_script().await;
init_verge_config().await; init_verge_config().await;
Config::verify_config_initialization().await; Config::verify_config_initialization().await;
init_window().await; init_window().await;