mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-01-29 00:35:38 +08:00
fix: enhance startup speed and fix connection issues during initialization
This commit is contained in:
@@ -331,8 +331,9 @@ pub fn run() {
|
||||
|
||||
logging!(info, Type::Setup, true, "执行主要设置操作...");
|
||||
|
||||
resolve::resolve_setup_handle(app_handle);
|
||||
resolve::resolve_setup_async();
|
||||
resolve::resolve_setup_sync(app_handle);
|
||||
resolve::resolve_setup_sync();
|
||||
|
||||
logging!(info, Type::Setup, true, "初始化完成,继续执行");
|
||||
Ok(())
|
||||
|
||||
@@ -90,12 +90,6 @@ pub async fn auto_lightweight_mode_init() -> Result<()> {
|
||||
);
|
||||
set_lightweight_mode(true).await;
|
||||
enable_auto_light_weight_mode().await;
|
||||
|
||||
// 确保托盘状态更新
|
||||
if let Err(e) = Tray::global().update_part().await {
|
||||
log::warn!("Failed to update tray: {e}");
|
||||
return Err(e);
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
||||
@@ -405,14 +405,6 @@ pub async fn init_resources() -> Result<()> {
|
||||
for file in file_list.iter() {
|
||||
let src_path = res_dir.join(file);
|
||||
let dest_path = app_dir.join(file);
|
||||
logging!(
|
||||
debug,
|
||||
Type::Setup,
|
||||
true,
|
||||
"src_path: {:?}, dest_path: {:?}",
|
||||
src_path,
|
||||
dest_path
|
||||
);
|
||||
|
||||
let handle_copy = |src: PathBuf, dest: PathBuf, file: String| async move {
|
||||
match fs::copy(&src, &dest).await {
|
||||
|
||||
@@ -16,11 +16,16 @@ pub mod ui;
|
||||
pub mod window;
|
||||
pub mod window_script;
|
||||
|
||||
pub fn resolve_setup_sync(app_handle: AppHandle) {
|
||||
pub fn resolve_setup_handle(app_handle: AppHandle) {
|
||||
init_handle(app_handle);
|
||||
init_scheme();
|
||||
init_embed_server();
|
||||
NetworkManager::new().init();
|
||||
}
|
||||
|
||||
pub fn resolve_setup_sync() {
|
||||
AsyncHandler::spawn(|| async {
|
||||
AsyncHandler::spawn_blocking(|| init_scheme());
|
||||
AsyncHandler::spawn_blocking(|| init_embed_server());
|
||||
AsyncHandler::spawn_blocking(|| NetworkManager::new().init());
|
||||
});
|
||||
}
|
||||
|
||||
pub fn resolve_setup_async() {
|
||||
@@ -33,28 +38,30 @@ pub fn resolve_setup_async() {
|
||||
std::thread::current().id()
|
||||
);
|
||||
|
||||
// AsyncHandler::spawn_blocking(|| AsyncHandler::block_on(init_work_config()));
|
||||
|
||||
AsyncHandler::spawn(|| async {
|
||||
init_work_config().await;
|
||||
init_resources().await;
|
||||
init_startup_script().await;
|
||||
futures::join!(
|
||||
init_work_config(),
|
||||
init_resources(),
|
||||
init_startup_script(),
|
||||
init_hotkey(),
|
||||
);
|
||||
|
||||
init_timer().await;
|
||||
init_hotkey().await;
|
||||
init_auto_lightweight_mode().await;
|
||||
|
||||
init_verge_config().await;
|
||||
init_core_manager().await;
|
||||
init_system_proxy().await;
|
||||
|
||||
init_system_proxy().await;
|
||||
AsyncHandler::spawn_blocking(|| {
|
||||
init_system_proxy_guard();
|
||||
});
|
||||
|
||||
init_window().await;
|
||||
init_tray().await;
|
||||
refresh_tray_menu().await
|
||||
let tray_and_refresh = async {
|
||||
init_tray().await;
|
||||
refresh_tray_menu().await;
|
||||
};
|
||||
futures::join!(init_window(), tray_and_refresh,);
|
||||
});
|
||||
|
||||
let elapsed = start_time.elapsed();
|
||||
|
||||
Reference in New Issue
Block a user