mirror of
https://github.com/clash-verge-rev/clash-verge-rev
synced 2025-05-05 06:53:44 +08:00
feat: add tray menu indicator for lightweight mode #3386
This commit is contained in:
parent
0646fa96a6
commit
824ad9fa29
@ -14,10 +14,12 @@
|
|||||||
- 静默启动异常窗口创建和关闭流程
|
- 静默启动异常窗口创建和关闭流程
|
||||||
- 使用 tauri window-state 管理窗口,尝试解决各种窗口异常
|
- 使用 tauri window-state 管理窗口,尝试解决各种窗口异常
|
||||||
- Windows 错误的全局快捷键 'Ctrl+Q' 注册
|
- Windows 错误的全局快捷键 'Ctrl+Q' 注册
|
||||||
|
- Vless URL 解码时网络类型错误
|
||||||
|
|
||||||
#### 新增了:
|
#### 新增了:
|
||||||
- 允许代理主机地址设置为非 127.0.0.1 对 WSL 代理友好
|
- 允许代理主机地址设置为非 127.0.0.1 对 WSL 代理友好
|
||||||
- 关闭系统代理时关闭已建立的网络连接
|
- 关闭系统代理时关闭已建立的网络连接
|
||||||
|
- 托盘显示当前轻量模式状态
|
||||||
|
|
||||||
#### 优化了:
|
#### 优化了:
|
||||||
- 系统代理 Bypass 设置
|
- 系统代理 Bypass 设置
|
||||||
|
@ -6,7 +6,10 @@ use crate::{
|
|||||||
cmd,
|
cmd,
|
||||||
config::Config,
|
config::Config,
|
||||||
feat,
|
feat,
|
||||||
module::{lightweight::entry_lightweight_mode, mihomo::Rate},
|
module::{
|
||||||
|
lightweight::{entry_lightweight_mode, is_in_lightweight_mode},
|
||||||
|
mihomo::Rate,
|
||||||
|
},
|
||||||
process::AsyncHandler,
|
process::AsyncHandler,
|
||||||
resolve,
|
resolve,
|
||||||
utils::{dirs::find_target_icons, i18n::t, logging::Type, resolve::VERSION},
|
utils::{dirs::find_target_icons, i18n::t, logging::Type, resolve::VERSION},
|
||||||
@ -254,6 +257,7 @@ impl Tray {
|
|||||||
.data()
|
.data()
|
||||||
.all_profile_uid_and_name()
|
.all_profile_uid_and_name()
|
||||||
.unwrap_or_default();
|
.unwrap_or_default();
|
||||||
|
let is_lightweight_mode = is_in_lightweight_mode();
|
||||||
|
|
||||||
let tray = app_handle.tray_by_id("main").unwrap();
|
let tray = app_handle.tray_by_id("main").unwrap();
|
||||||
let _ = tray.set_menu(Some(create_tray_menu(
|
let _ = tray.set_menu(Some(create_tray_menu(
|
||||||
@ -262,6 +266,7 @@ impl Tray {
|
|||||||
*system_proxy,
|
*system_proxy,
|
||||||
*tun_mode,
|
*tun_mode,
|
||||||
profile_uid_and_name,
|
profile_uid_and_name,
|
||||||
|
is_lightweight_mode,
|
||||||
)?));
|
)?));
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@ -456,6 +461,7 @@ fn create_tray_menu(
|
|||||||
system_proxy_enabled: bool,
|
system_proxy_enabled: bool,
|
||||||
tun_mode_enabled: bool,
|
tun_mode_enabled: bool,
|
||||||
profile_uid_and_name: Vec<(String, String)>,
|
profile_uid_and_name: Vec<(String, String)>,
|
||||||
|
is_lightweight_mode: bool,
|
||||||
) -> Result<tauri::menu::Menu<Wry>> {
|
) -> Result<tauri::menu::Menu<Wry>> {
|
||||||
let mode = mode.unwrap_or("");
|
let mode = mode.unwrap_or("");
|
||||||
let version = VERSION.get().unwrap();
|
let version = VERSION.get().unwrap();
|
||||||
@ -566,11 +572,12 @@ fn create_tray_menu(
|
|||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let lighteweight_mode = &MenuItem::with_id(
|
let lighteweight_mode = &CheckMenuItem::with_id(
|
||||||
app_handle,
|
app_handle,
|
||||||
"entry_lightweight_mode",
|
"entry_lightweight_mode",
|
||||||
t("LightWeight Mode"),
|
t("LightWeight Mode"),
|
||||||
true,
|
true,
|
||||||
|
is_lightweight_mode,
|
||||||
hotkeys.get("entry_lightweight_mode").map(|s| s.as_str()),
|
hotkeys.get("entry_lightweight_mode").map(|s| s.as_str()),
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
config::Config,
|
config::Config,
|
||||||
core::{handle, timer::Timer},
|
core::{handle, timer::Timer, tray::Tray},
|
||||||
log_err, logging, logging_error,
|
log_err, logging, logging_error,
|
||||||
utils::logging::Type,
|
utils::logging::Type,
|
||||||
AppHandleManager,
|
AppHandleManager,
|
||||||
@ -64,6 +64,8 @@ pub fn entry_lightweight_mode() {
|
|||||||
// 标记已进入轻量模式
|
// 标记已进入轻量模式
|
||||||
set_lightweight_mode(true);
|
set_lightweight_mode(true);
|
||||||
let _ = cancel_light_weight_timer();
|
let _ = cancel_light_weight_timer();
|
||||||
|
|
||||||
|
logging_error!(Type::Tray, true, Tray::global().update_menu());
|
||||||
}
|
}
|
||||||
|
|
||||||
// 从轻量模式恢复
|
// 从轻量模式恢复
|
||||||
@ -74,6 +76,8 @@ pub fn exit_lightweight_mode() {
|
|||||||
|
|
||||||
// 重置UI就绪状态
|
// 重置UI就绪状态
|
||||||
crate::utils::resolve::reset_ui_ready();
|
crate::utils::resolve::reset_ui_ready();
|
||||||
|
|
||||||
|
logging_error!(Type::Tray, true, Tray::global().update_menu());
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn add_light_weight_timer() {
|
pub fn add_light_weight_timer() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user