From 5d2e114b4d7bde83de1a2cf934a3cda5c92735d3 Mon Sep 17 00:00:00 2001 From: Tunglies <77394545+Tunglies@users.noreply.github.com> Date: Thu, 18 Sep 2025 00:46:01 +0800 Subject: [PATCH] fix: Update tray menu event handling to toggle lightweight mode based on current state #4785 --- UPDATELOG.md | 1 + src-tauri/src/core/tray/mod.rs | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/UPDATELOG.md b/UPDATELOG.md index 52f91945a..818eda2ed 100644 --- a/UPDATELOG.md +++ b/UPDATELOG.md @@ -8,6 +8,7 @@ - 优化服务模式重装逻辑,避免不必要的重复检查 - 修复轻量模式退出无响应的问题 +- 修复托盘轻量模式支持退出/进入 - macOS Tun/系统代理 模式下图标大小不统一 - 托盘节点切换不再显示隐藏组 diff --git a/src-tauri/src/core/tray/mod.rs b/src-tauri/src/core/tray/mod.rs index 7317fbf87..45f0248ae 100644 --- a/src-tauri/src/core/tray/mod.rs +++ b/src-tauri/src/core/tray/mod.rs @@ -997,7 +997,12 @@ fn on_menu_event(_: &AppHandle, event: MenuEvent) { if !should_handle_tray_click() { return; } - lightweight::entry_lightweight_mode().await; // Await async function + + if !is_in_lightweight_mode() { + lightweight::entry_lightweight_mode().await; // Await async function + } else { + lightweight::exit_lightweight_mode().await; // Await async function + } } "quit" => { feat::quit().await; // Await async function