feat: add tray menu indicator for lightweight mode #3386

This commit is contained in:
Tunglies
2025-04-21 04:33:56 +08:00
parent 0646fa96a6
commit 824ad9fa29
3 changed files with 16 additions and 3 deletions

View File

@@ -6,7 +6,10 @@ use crate::{
cmd,
config::Config,
feat,
module::{lightweight::entry_lightweight_mode, mihomo::Rate},
module::{
lightweight::{entry_lightweight_mode, is_in_lightweight_mode},
mihomo::Rate,
},
process::AsyncHandler,
resolve,
utils::{dirs::find_target_icons, i18n::t, logging::Type, resolve::VERSION},
@@ -254,6 +257,7 @@ impl Tray {
.data()
.all_profile_uid_and_name()
.unwrap_or_default();
let is_lightweight_mode = is_in_lightweight_mode();
let tray = app_handle.tray_by_id("main").unwrap();
let _ = tray.set_menu(Some(create_tray_menu(
@@ -262,6 +266,7 @@ impl Tray {
*system_proxy,
*tun_mode,
profile_uid_and_name,
is_lightweight_mode,
)?));
Ok(())
}
@@ -456,6 +461,7 @@ fn create_tray_menu(
system_proxy_enabled: bool,
tun_mode_enabled: bool,
profile_uid_and_name: Vec<(String, String)>,
is_lightweight_mode: bool,
) -> Result<tauri::menu::Menu<Wry>> {
let mode = mode.unwrap_or("");
let version = VERSION.get().unwrap();
@@ -566,11 +572,12 @@ fn create_tray_menu(
)
.unwrap();
let lighteweight_mode = &MenuItem::with_id(
let lighteweight_mode = &CheckMenuItem::with_id(
app_handle,
"entry_lightweight_mode",
t("LightWeight Mode"),
true,
is_lightweight_mode,
hotkeys.get("entry_lightweight_mode").map(|s| s.as_str()),
)
.unwrap();