diff --git a/UPDATELOG.md b/UPDATELOG.md index 471109b7..f962da3b 100644 --- a/UPDATELOG.md +++ b/UPDATELOG.md @@ -6,7 +6,8 @@ 代号释义: 本次发布在功能上的大幅扩展。新首页设计为用户带来全新交互体验,DNS 覆写功能增强网络控制能力,解锁测试页面助力内容访问自由度提升,轻量模式提供灵活使用选择。此外,macOS 应用菜单集成、sidecar 模式、诊断信息导出等新特性进一步丰富了软件的适用场景。这些新增功能显著拓宽了 Clash Verge 的功能边界,为用户提供了更强大的工具和可能性。 -2.2.1 相对于 2.2.0(已下架不在提供) 修复了: +2.2.1 相对于 2.2.0(已下架不在提供) +修复了: 1. **首页** - 修复 Direct 模式首页无法渲染。 - 修复 首页启用轻量模式导致 ClashVergeRev 从托盘退出。 @@ -21,6 +22,11 @@ - 增加 服务器模式下启动mihomo内核的时候查找并停止其他已经存在的内核进程,防止内核假死等问题带来的通信失败。 3. **界面** - 修复 连接详情卡没有跟随主题色 + +新增了: +1. **轻量模式** + - 新增托盘进入轻量模式支持 + - 新增进入轻量模式快捷键支持 --- diff --git a/src-tauri/src/core/hotkey.rs b/src-tauri/src/core/hotkey.rs index f2e48f5f..f15c082a 100755 --- a/src-tauri/src/core/hotkey.rs +++ b/src-tauri/src/core/hotkey.rs @@ -1,4 +1,4 @@ -use crate::{config::Config, core::handle, feat, log_err, utils::resolve}; +use crate::{config::Config, core::handle, feat, log_err, module::lightweight, utils::resolve}; use anyhow::{bail, Result}; use once_cell::sync::OnceCell; use parking_lot::Mutex; @@ -147,6 +147,7 @@ impl Hotkey { "clash_mode_direct" => || feat::change_clash_mode("direct".into()), "toggle_system_proxy" => || feat::toggle_system_proxy(), "toggle_tun_mode" => || feat::toggle_tun_mode(None), + "entry_lightweight_mode" => || feat::lightweight_mode(), "quit" => || feat::quit(Some(0)), #[cfg(target_os = "macos")] "hide" => || feat::hide(), diff --git a/src-tauri/src/core/tray/mod.rs b/src-tauri/src/core/tray/mod.rs index ae2b1002..4f7237b4 100644 --- a/src-tauri/src/core/tray/mod.rs +++ b/src-tauri/src/core/tray/mod.rs @@ -6,7 +6,7 @@ use crate::{ cmd, config::Config, feat, - module::mihomo::Rate, + module::{lightweight, mihomo::Rate}, resolve, utils::{dirs, i18n::t, resolve::VERSION}, }; @@ -94,6 +94,7 @@ impl Tray { tray.on_tray_icon_event(|_, event| { let tray_event = { Config::verge().latest().tray_event.clone() }; let tray_event: String = tray_event.unwrap_or("main_window".into()); + log::debug!(target: "app","tray event: {:?}", tray_event); if let TrayIconEvent::Click { button: MouseButton::Left, @@ -525,6 +526,15 @@ fn create_tray_menu( ) .unwrap(); + let lighteweight_mode = &MenuItem::with_id( + app_handle, + "entry_lightweight_mode", + t("Lightweight Mode"), + true, + hotkeys.get("entry_lightweight_mode").map(|s| s.as_str()), + ) + .unwrap(); + let copy_env = &MenuItem::with_id(app_handle, "copy_env", t("Copy Env"), true, None::<&str>).unwrap(); @@ -617,6 +627,8 @@ fn create_tray_menu( separator, system_proxy, tun_mode, + separator, + lighteweight_mode, copy_env, open_dir, more, @@ -644,6 +656,7 @@ fn on_menu_event(_: &AppHandle, event: MenuEvent) { "open_logs_dir" => crate::log_err!(cmd::open_logs_dir()), "restart_clash" => feat::restart_clash_core(), "restart_app" => feat::restart_app(), + "entry_lightweight_mode" => feat::lightweight_mode(), "quit" => { println!("quit"); feat::quit(Some(0)); diff --git a/src-tauri/src/feat/lightweight.rs b/src-tauri/src/feat/lightweight.rs new file mode 100644 index 00000000..6e64f0f6 --- /dev/null +++ b/src-tauri/src/feat/lightweight.rs @@ -0,0 +1,6 @@ +use crate::module::lightweight::entry_lightweight_mode; + +pub fn lightweight_mode() { + log::info!(target: "app","Lightweight mode enabled"); + entry_lightweight_mode(); +} diff --git a/src-tauri/src/feat/mod.rs b/src-tauri/src/feat/mod.rs index 02a65a44..32814194 100644 --- a/src-tauri/src/feat/mod.rs +++ b/src-tauri/src/feat/mod.rs @@ -1,6 +1,7 @@ mod backup; mod clash; mod config; +mod lightweight; mod profile; mod proxy; mod window; @@ -9,6 +10,7 @@ mod window; pub use backup::*; pub use clash::*; pub use config::*; +pub use lightweight::*; pub use profile::*; pub use proxy::*; pub use window::*; diff --git a/src-tauri/src/module/lightweight.rs b/src-tauri/src/module/lightweight.rs index a853d611..224b75e6 100644 --- a/src-tauri/src/module/lightweight.rs +++ b/src-tauri/src/module/lightweight.rs @@ -26,12 +26,14 @@ pub fn disable_auto_light_weight_mode() { pub fn entry_lightweight_mode() { if let Some(window) = handle::Handle::global().get_window() { + if window.is_visible().unwrap_or(false) { + let _ = window.hide(); + } if let Some(webview) = window.get_webview_window("main") { let _ = webview.destroy(); - let _ = window.hide(); - println!("[lightweight_mode] 轻量模式已开启"); - log::info!(target: "app", "[lightweight_mode] 轻量模式已开启"); } + println!("[lightweight_mode] 轻量模式已开启"); + log::info!(target: "app", "[lightweight_mode] 轻量模式已开启"); } let _ = cancel_light_weight_timer(); } diff --git a/src/components/setting/mods/hotkey-viewer.tsx b/src/components/setting/mods/hotkey-viewer.tsx index b4307af2..feaac70b 100644 --- a/src/components/setting/mods/hotkey-viewer.tsx +++ b/src/components/setting/mods/hotkey-viewer.tsx @@ -20,6 +20,7 @@ const HOTKEY_FUNC = [ "clash_mode_direct", "toggle_system_proxy", "toggle_tun_mode", + "entry_lightweight_mode", ]; export const HotkeyViewer = forwardRef((props, ref) => { diff --git a/src/locales/en.json b/src/locales/en.json index 0d2a908d..9ddda072 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -353,6 +353,7 @@ "clash_mode_direct": "Direct Mode", "toggle_system_proxy": "Enable/Disable System Proxy", "toggle_tun_mode": "Enable/Disable Tun Mode", + "entry_lightweight_mode": "Entry Lightweight Mode", "Backup Setting": "Backup Setting", "Backup Setting Info": "Support WebDAV backup configuration files", "Runtime Config": "Runtime Config", diff --git a/src/locales/zh.json b/src/locales/zh.json index f924c0ad..a6b3b586 100644 --- a/src/locales/zh.json +++ b/src/locales/zh.json @@ -353,6 +353,7 @@ "clash_mode_direct": "直连模式", "toggle_system_proxy": "打开/关闭系统代理", "toggle_tun_mode": "打开/关闭 TUN 模式", + "toggle_lightweight_mode": "进入轻量模式", "Backup Setting": "备份设置", "Backup Setting Info": "支持 WebDAV 备份配置文件", "Runtime Config": "当前配置",