refactor: use async approach to restructure UI startup logic and resolve various freeze issues during launch

This commit is contained in:
wonfen
2025-05-10 01:25:50 +08:00
parent b5b65ac8c5
commit 8cae9d4e0a
11 changed files with 648 additions and 616 deletions

View File

@@ -16,8 +16,6 @@ use std::{
};
use tauri::{Listener, Manager};
pub static AUTO_LIGHT_WEIGHT_MODE_INIT: OnceCell<()> = OnceCell::new();
const LIGHT_WEIGHT_TASK_UID: &str = "light_weight_task";
// 轻量模式状态标志
@@ -217,19 +215,3 @@ fn cancel_light_weight_timer() -> Result<()> {
Ok(())
}
pub fn run_once_auto_lightweight() {
AUTO_LIGHT_WEIGHT_MODE_INIT.get_or_init(|| {
let is_silent_start = { Config::verge().data().enable_silent_start }.unwrap_or(false);
let enable_auto = { Config::verge().data().enable_auto_light_weight_mode }.unwrap_or(false);
if enable_auto && is_silent_start {
logging!(
info,
Type::Lightweight,
true,
"Add timer listener when creating window in silent start mode"
);
enable_auto_light_weight_mode();
}
});
}