fix: enhance startup speed and fix connection issues during initialization
This commit is contained in:
@@ -7,6 +7,7 @@
|
|||||||
### 🚀 性能优化
|
### 🚀 性能优化
|
||||||
|
|
||||||
- 优化内存占用
|
- 优化内存占用
|
||||||
|
- 优化启动速度
|
||||||
|
|
||||||
### 🐞 修复问题
|
### 🐞 修复问题
|
||||||
|
|
||||||
@@ -17,6 +18,7 @@
|
|||||||
- 修复托盘轻量模式状态检测异常
|
- 修复托盘轻量模式状态检测异常
|
||||||
- 修复通过 scheme 导入订阅崩溃
|
- 修复通过 scheme 导入订阅崩溃
|
||||||
- 修复单例检测实效
|
- 修复单例检测实效
|
||||||
|
- 修复启动阶段可能导致的无法连接内核
|
||||||
|
|
||||||
### 👙 界面样式
|
### 👙 界面样式
|
||||||
|
|
||||||
|
|||||||
@@ -331,8 +331,9 @@ pub fn run() {
|
|||||||
|
|
||||||
logging!(info, Type::Setup, true, "执行主要设置操作...");
|
logging!(info, Type::Setup, true, "执行主要设置操作...");
|
||||||
|
|
||||||
|
resolve::resolve_setup_handle(app_handle);
|
||||||
resolve::resolve_setup_async();
|
resolve::resolve_setup_async();
|
||||||
resolve::resolve_setup_sync(app_handle);
|
resolve::resolve_setup_sync();
|
||||||
|
|
||||||
logging!(info, Type::Setup, true, "初始化完成,继续执行");
|
logging!(info, Type::Setup, true, "初始化完成,继续执行");
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|||||||
@@ -90,12 +90,6 @@ pub async fn auto_lightweight_mode_init() -> Result<()> {
|
|||||||
);
|
);
|
||||||
set_lightweight_mode(true).await;
|
set_lightweight_mode(true).await;
|
||||||
enable_auto_light_weight_mode().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(())
|
Ok(())
|
||||||
|
|||||||
@@ -405,14 +405,6 @@ pub async fn init_resources() -> Result<()> {
|
|||||||
for file in file_list.iter() {
|
for file in file_list.iter() {
|
||||||
let src_path = res_dir.join(file);
|
let src_path = res_dir.join(file);
|
||||||
let dest_path = app_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 {
|
let handle_copy = |src: PathBuf, dest: PathBuf, file: String| async move {
|
||||||
match fs::copy(&src, &dest).await {
|
match fs::copy(&src, &dest).await {
|
||||||
|
|||||||
@@ -16,11 +16,16 @@ pub mod ui;
|
|||||||
pub mod window;
|
pub mod window;
|
||||||
pub mod window_script;
|
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_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() {
|
pub fn resolve_setup_async() {
|
||||||
@@ -33,28 +38,30 @@ pub fn resolve_setup_async() {
|
|||||||
std::thread::current().id()
|
std::thread::current().id()
|
||||||
);
|
);
|
||||||
|
|
||||||
// AsyncHandler::spawn_blocking(|| AsyncHandler::block_on(init_work_config()));
|
|
||||||
|
|
||||||
AsyncHandler::spawn(|| async {
|
AsyncHandler::spawn(|| async {
|
||||||
init_work_config().await;
|
futures::join!(
|
||||||
init_resources().await;
|
init_work_config(),
|
||||||
init_startup_script().await;
|
init_resources(),
|
||||||
|
init_startup_script(),
|
||||||
|
init_hotkey(),
|
||||||
|
);
|
||||||
|
|
||||||
init_timer().await;
|
init_timer().await;
|
||||||
init_hotkey().await;
|
|
||||||
init_auto_lightweight_mode().await;
|
init_auto_lightweight_mode().await;
|
||||||
|
|
||||||
init_verge_config().await;
|
init_verge_config().await;
|
||||||
init_core_manager().await;
|
init_core_manager().await;
|
||||||
init_system_proxy().await;
|
|
||||||
|
|
||||||
|
init_system_proxy().await;
|
||||||
AsyncHandler::spawn_blocking(|| {
|
AsyncHandler::spawn_blocking(|| {
|
||||||
init_system_proxy_guard();
|
init_system_proxy_guard();
|
||||||
});
|
});
|
||||||
|
|
||||||
init_window().await;
|
let tray_and_refresh = async {
|
||||||
init_tray().await;
|
init_tray().await;
|
||||||
refresh_tray_menu().await
|
refresh_tray_menu().await;
|
||||||
|
};
|
||||||
|
futures::join!(init_window(), tray_and_refresh,);
|
||||||
});
|
});
|
||||||
|
|
||||||
let elapsed = start_time.elapsed();
|
let elapsed = start_time.elapsed();
|
||||||
|
|||||||
Reference in New Issue
Block a user