mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-01-29 08:45:41 +08:00
feat: implement auto lightweight mode timer functionality
This commit implements the automatic lightweight mode feature with timer functionality: - Rename configuration properties from auto_enter_lite_mode to enable_auto_light_weight_mode and auto_enter_lite_mode_delay to auto_light_weight_minutes for better clarity - Add window event listeners to detect when window is closed or gets focus - Implement timer system to automatically enter lightweight mode after configured time - Remove exit_lightweight_mode function as it's no longer needed with the new implementation - Update UI components to reflect the new property names - Add logging for lightweight mode operations - Initialize lightweight mode based on user configuration at startup The feature now allows users to set a timer that will automatically enter lightweight mode after closing the main window, which can be cancelled by focusing the window again.
This commit is contained in:
@@ -1,11 +1,7 @@
|
||||
#[cfg(target_os = "macos")]
|
||||
use crate::AppHandleManager;
|
||||
use crate::{
|
||||
config::{Config, IVerge, PrfItem},
|
||||
core::*,
|
||||
log_err,
|
||||
utils::{error, init, server},
|
||||
wrap_err,
|
||||
config::{Config, IVerge, PrfItem}, core::*, log_err, module::lightweight, utils::{error, init, server}, wrap_err
|
||||
};
|
||||
use anyhow::{bail, Result};
|
||||
use once_cell::sync::OnceCell;
|
||||
@@ -115,6 +111,11 @@ pub async fn resolve_setup(app: &mut App) {
|
||||
|
||||
log_err!(tray::Tray::global().update_part());
|
||||
log_err!(timer::Timer::global().init());
|
||||
|
||||
let enable_auto_light_weight_mode = { Config::verge().data().enable_auto_light_weight_mode };
|
||||
if enable_auto_light_weight_mode.unwrap_or(false) {
|
||||
lightweight::enable_auto_light_weight_mode();
|
||||
}
|
||||
}
|
||||
|
||||
/// reset system proxy
|
||||
|
||||
Reference in New Issue
Block a user