mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-01-29 08:45:41 +08:00
fix: auto enable light mode config does not take effect when silent s… (#3344)
* fix: auto enable light mode config does not take effect when silent start is enabled * refactor: extract run_once_lightweight logic into lightweight.rs as a fn
This commit is contained in:
@@ -1,7 +1,3 @@
|
||||
use anyhow::{Context, Result};
|
||||
use delay_timer::prelude::TaskBuilder;
|
||||
use tauri::{Listener, Manager};
|
||||
|
||||
use crate::{
|
||||
config::Config,
|
||||
core::{handle, timer::Timer},
|
||||
@@ -10,6 +6,13 @@ use crate::{
|
||||
AppHandleManager,
|
||||
};
|
||||
|
||||
use anyhow::{Context, Result};
|
||||
use delay_timer::prelude::TaskBuilder;
|
||||
use once_cell::sync::OnceCell;
|
||||
use tauri::{Listener, Manager};
|
||||
|
||||
pub static AUTO_LIGHT_WEIGHT_MODE_INIT: OnceCell<()> = OnceCell::new();
|
||||
|
||||
const LIGHT_WEIGHT_TASK_UID: &str = "light_weight_task";
|
||||
|
||||
pub fn enable_auto_light_weight_mode() {
|
||||
@@ -143,3 +146,19 @@ 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();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user