feat: show detailed results in hotkey notifications (#6639)

* feat: show detailed results in hotkey notifications

* fix: Japanese locale appears to have a truncated translation key label

* fix: variable naming

* Update documentation to English

* Remove unnecessary mut

* feat: enhance system proxy notifications with toggle state

* chore: update changelog to include new shortcut notification feature

* fix: remove unnecessary quotes from system proxy toggle messages in localization files

* fix: tun mode toggled hotkey notifications

* fix: correct toggle_tun_mode logic to handle current state and errors

---------

Co-authored-by: Tunglies <77394545+Tunglies@users.noreply.github.com>
This commit is contained in:
wysha-object 2026-03-31 01:06:45 +08:00 committed by GitHub
parent 071f92635f
commit b7230967b4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
17 changed files with 93 additions and 44 deletions

View File

@ -11,6 +11,8 @@
### ✨ 新增功能 ### ✨ 新增功能
- 快捷键操作通知操作结果
### 🚀 优化改进 ### 🚀 优化改进
- 优化 macOS 读取系统代理性能 - 优化 macOS 读取系统代理性能

View File

@ -8,10 +8,12 @@ notifications:
body: تم التبديل إلى {mode}. body: تم التبديل إلى {mode}.
systemProxyToggled: systemProxyToggled:
title: وكيل النظام title: وكيل النظام
body: تم تحديث حالة وكيل النظام. 'on': System proxy has been enabled.
'off': System proxy has been disabled.
tunModeToggled: tunModeToggled:
title: وضع TUN title: وضع TUN
body: تم تحديث حالة وضع TUN. 'on': TUN mode has been enabled.
'off': TUN mode has been disabled.
lightweightModeEntered: lightweightModeEntered:
title: الوضع الخفيف title: الوضع الخفيف
body: تم الدخول إلى الوضع الخفيف. body: تم الدخول إلى الوضع الخفيف.

View File

@ -8,10 +8,12 @@ notifications:
body: Auf {mode} umgeschaltet. body: Auf {mode} umgeschaltet.
systemProxyToggled: systemProxyToggled:
title: Systemproxy title: Systemproxy
body: Der Status des Systemproxys wurde aktualisiert. 'on': System proxy has been enabled.
'off': System proxy has been disabled.
tunModeToggled: tunModeToggled:
title: TUN-Modus title: TUN-Modus
body: Der Status des TUN-Modus wurde aktualisiert. 'on': TUN mode has been enabled.
'off': TUN mode has been disabled.
lightweightModeEntered: lightweightModeEntered:
title: Leichtmodus title: Leichtmodus
body: Leichtmodus aktiviert. body: Leichtmodus aktiviert.

View File

@ -8,10 +8,12 @@ notifications:
body: Switched to {mode}. body: Switched to {mode}.
systemProxyToggled: systemProxyToggled:
title: System Proxy title: System Proxy
body: System proxy status has been updated. 'on': System proxy has been enabled.
'off': System proxy has been disabled.
tunModeToggled: tunModeToggled:
title: TUN Mode title: TUN Mode
body: TUN mode status has been updated. 'on': TUN mode has been enabled.
'off': TUN mode has been disabled.
lightweightModeEntered: lightweightModeEntered:
title: Lightweight Mode title: Lightweight Mode
body: Entered lightweight mode. body: Entered lightweight mode.

View File

@ -8,10 +8,12 @@ notifications:
body: Cambiado a {mode}. body: Cambiado a {mode}.
systemProxyToggled: systemProxyToggled:
title: Proxy del sistema title: Proxy del sistema
body: El estado del proxy del sistema se ha actualizado. 'on': System proxy has been enabled.
'off': System proxy has been disabled.
tunModeToggled: tunModeToggled:
title: Modo TUN title: Modo TUN
body: El estado del modo TUN se ha actualizado. 'on': TUN mode has been enabled.
'off': TUN mode has been disabled.
lightweightModeEntered: lightweightModeEntered:
title: Modo ligero title: Modo ligero
body: Se ha entrado en el modo ligero. body: Se ha entrado en el modo ligero.

View File

@ -8,10 +8,12 @@ notifications:
body: به {mode} تغییر کرد. body: به {mode} تغییر کرد.
systemProxyToggled: systemProxyToggled:
title: پروکسی سیستم title: پروکسی سیستم
body: وضعیت پروکسی سیستم به‌روزرسانی شد. 'on': System proxy has been enabled.
'off': System proxy has been disabled.
tunModeToggled: tunModeToggled:
title: حالت TUN title: حالت TUN
body: وضعیت حالت TUN به‌روزرسانی شد. 'on': TUN mode has been enabled.
'off': TUN mode has been disabled.
lightweightModeEntered: lightweightModeEntered:
title: حالت سبک title: حالت سبک
body: به حالت سبک وارد شد. body: به حالت سبک وارد شد.

View File

@ -8,10 +8,12 @@ notifications:
body: Beralih ke {mode}. body: Beralih ke {mode}.
systemProxyToggled: systemProxyToggled:
title: Proksi Sistem title: Proksi Sistem
body: Status proksi sistem telah diperbarui. 'on': System proxy has been enabled.
'off': System proxy has been disabled.
tunModeToggled: tunModeToggled:
title: Mode TUN title: Mode TUN
body: Status mode TUN telah diperbarui. 'on': TUN mode has been enabled.
'off': TUN mode has been disabled.
lightweightModeEntered: lightweightModeEntered:
title: Mode Ringan title: Mode Ringan
body: Masuk ke mode ringan. body: Masuk ke mode ringan.

View File

@ -8,10 +8,12 @@ notifications:
body: '{mode} に切り替えました。' body: '{mode} に切り替えました。'
systemProxyToggled: systemProxyToggled:
title: システムプロキシ title: システムプロキシ
body: システムプロキシの状態が更新されました。 'on': System proxy has been enabled.
'off': System proxy has been disabled.
tunModeToggled: tunModeToggled:
title: TUN モード title: TUN モード
body: TUN モードの状態が更新されました。 'on': TUN mode has been enabled.
'off': TUN mode has been disabled.
lightweightModeEntered: lightweightModeEntered:
title: 軽量モード title: 軽量モード
body: 軽量モードに入りました。 body: 軽量モードに入りました。

View File

@ -8,10 +8,12 @@ notifications:
body: '{mode}(으)로 전환되었습니다.' body: '{mode}(으)로 전환되었습니다.'
systemProxyToggled: systemProxyToggled:
title: 시스템 프록시 title: 시스템 프록시
body: 시스템 프록시 상태가 업데이트되었습니다. 'on': System proxy has been enabled.
'off': System proxy has been disabled.
tunModeToggled: tunModeToggled:
title: TUN 모드 title: TUN 모드
body: TUN 모드 상태가 업데이트되었습니다. 'on': TUN mode has been enabled.
'off': TUN mode has been disabled.
lightweightModeEntered: lightweightModeEntered:
title: 경량 모드 title: 경량 모드
body: 경량 모드에 진입했습니다. body: 경량 모드에 진입했습니다.

View File

@ -8,10 +8,12 @@ notifications:
body: Переключено на {mode}. body: Переключено на {mode}.
systemProxyToggled: systemProxyToggled:
title: Системный прокси title: Системный прокси
body: Статус системного прокси обновлен. 'on': System proxy has been enabled.
'off': System proxy has been disabled.
tunModeToggled: tunModeToggled:
title: Режим TUN title: Режим TUN
body: Статус режима TUN обновлен. 'on': TUN mode has been enabled.
'off': TUN mode has been disabled.
lightweightModeEntered: lightweightModeEntered:
title: Легкий режим title: Легкий режим
body: Включен легкий режим. body: Включен легкий режим.

View File

@ -8,10 +8,12 @@ notifications:
body: '{mode} moduna geçildi.' body: '{mode} moduna geçildi.'
systemProxyToggled: systemProxyToggled:
title: Sistem Vekil'i title: Sistem Vekil'i
body: Sistem vekil'i durumu güncellendi. 'on': System proxy has been enabled.
'off': System proxy has been disabled.
tunModeToggled: tunModeToggled:
title: TUN Modu title: TUN Modu
body: TUN modu durumu güncellendi. 'on': TUN mode has been enabled.
'off': TUN mode has been disabled.
lightweightModeEntered: lightweightModeEntered:
title: Hafif Mod title: Hafif Mod
body: Hafif moda geçildi. body: Hafif moda geçildi.

View File

@ -8,10 +8,12 @@ notifications:
body: '{mode} режимына күчтел.' body: '{mode} режимына күчтел.'
systemProxyToggled: systemProxyToggled:
title: Системалы прокси title: Системалы прокси
body: Системалы прокси хәле яңартылды. 'on': System proxy has been enabled.
'off': System proxy has been disabled.
tunModeToggled: tunModeToggled:
title: TUN режимы title: TUN режимы
body: TUN режимы хәле яңартылды. 'on': TUN mode has been enabled.
'off': TUN mode has been disabled.
lightweightModeEntered: lightweightModeEntered:
title: Җиңел режим title: Җиңел режим
body: Җиңел режимга күчелде. body: Җиңел режимга күчелде.

View File

@ -8,10 +8,12 @@ notifications:
body: 已切换至 {mode}。 body: 已切换至 {mode}。
systemProxyToggled: systemProxyToggled:
title: 系统代理 title: 系统代理
body: 系统代理状态已更新。 'on': 系统代理已启用。
'off': 系统代理已禁用。
tunModeToggled: tunModeToggled:
title: TUN 模式 title: TUN 模式
body: TUN 模式状态已更新。 'on': TUN 模式已开启。
'off': TUN 模式已关闭。
lightweightModeEntered: lightweightModeEntered:
title: 轻量模式 title: 轻量模式
body: 已进入轻量模式。 body: 已进入轻量模式。

View File

@ -8,10 +8,12 @@ notifications:
body: 已切換至 {mode}。 body: 已切換至 {mode}。
systemProxyToggled: systemProxyToggled:
title: 系統代理 title: 系統代理
body: 系統代理狀態已更新。 'on': System proxy has been enabled.
'off': System proxy has been disabled.
tunModeToggled: tunModeToggled:
title: 虛擬網路介面卡模式 title: 虛擬網路介面卡模式
body: 已更新虛擬網路介面卡模式狀態。 'on': TUN mode has been enabled.
'off': TUN mode has been disabled.
lightweightModeEntered: lightweightModeEntered:
title: 輕量模式 title: 輕量模式
body: 已進入輕量模式。 body: 已進入輕量模式。

View File

@ -135,14 +135,14 @@ impl Hotkey {
} }
HotkeyFunction::ToggleSystemProxy => { HotkeyFunction::ToggleSystemProxy => {
AsyncHandler::spawn(async move || { AsyncHandler::spawn(async move || {
feat::toggle_system_proxy().await; let is_proxy_enabled = feat::toggle_system_proxy().await;
notify_event(NotificationEvent::SystemProxyToggled).await; notify_event(NotificationEvent::SystemProxyToggled(is_proxy_enabled)).await;
}); });
} }
HotkeyFunction::ToggleTunMode => { HotkeyFunction::ToggleTunMode => {
AsyncHandler::spawn(async move || { AsyncHandler::spawn(async move || {
feat::toggle_tun_mode(None).await; let is_tun_enable = feat::toggle_tun_mode(None).await;
notify_event(NotificationEvent::TunModeToggled).await; notify_event(NotificationEvent::TunModeToggled(is_tun_enable)).await;
}); });
} }
HotkeyFunction::EntryLightweightMode => { HotkeyFunction::EntryLightweightMode => {

View File

@ -7,7 +7,7 @@ use std::env;
use tauri_plugin_clipboard_manager::ClipboardExt as _; use tauri_plugin_clipboard_manager::ClipboardExt as _;
/// Toggle system proxy on/off /// Toggle system proxy on/off
pub async fn toggle_system_proxy() { pub async fn toggle_system_proxy() -> bool {
let verge = Config::verge().await; let verge = Config::verge().await;
let enable = verge.latest_arc().enable_system_proxy.unwrap_or(false); let enable = verge.latest_arc().enable_system_proxy.unwrap_or(false);
let auto_close_connection = verge.latest_arc().auto_close_connection.unwrap_or(false); let auto_close_connection = verge.latest_arc().auto_close_connection.unwrap_or(false);
@ -20,9 +20,10 @@ pub async fn toggle_system_proxy() {
logging!(error, Type::ProxyMode, "Failed to close all connections: {err}"); logging!(error, Type::ProxyMode, "Failed to close all connections: {err}");
} }
let enable = !enable;
let patch_result = super::patch_verge( let patch_result = super::patch_verge(
&IVerge { &IVerge {
enable_system_proxy: Some(!enable), enable_system_proxy: Some(enable),
..IVerge::default() ..IVerge::default()
}, },
false, false,
@ -33,24 +34,33 @@ pub async fn toggle_system_proxy() {
Ok(_) => handle::Handle::refresh_verge(), Ok(_) => handle::Handle::refresh_verge(),
Err(err) => logging!(error, Type::ProxyMode, "{err}"), Err(err) => logging!(error, Type::ProxyMode, "{err}"),
} }
enable
} }
/// Toggle TUN mode on/off /// Toggle TUN mode on/off
pub async fn toggle_tun_mode(not_save_file: Option<bool>) { /// Returns the updated toggle state
let enable = Config::verge().await.latest_arc().enable_tun_mode; pub async fn toggle_tun_mode(not_save_file: Option<bool>) -> bool {
let enable = enable.unwrap_or(false); let current = Config::verge().await.latest_arc().enable_tun_mode.unwrap_or(false);
let enable = !current;
match super::patch_verge( match super::patch_verge(
&IVerge { &IVerge {
enable_tun_mode: Some(!enable), enable_tun_mode: Some(enable),
..IVerge::default() ..IVerge::default()
}, },
not_save_file.unwrap_or(false), not_save_file.unwrap_or(false),
) )
.await .await
{ {
Ok(_) => handle::Handle::refresh_verge(), Ok(_) => {
Err(err) => logging!(error, Type::ProxyMode, "{err}"), handle::Handle::refresh_verge();
enable
}
Err(err) => {
logging!(error, Type::ProxyMode, "{err}");
current
}
} }
} }

View File

@ -9,8 +9,8 @@ pub enum NotificationEvent<'a> {
ClashModeChanged { ClashModeChanged {
mode: &'a str, mode: &'a str,
}, },
SystemProxyToggled, SystemProxyToggled(bool),
TunModeToggled, TunModeToggled(bool),
LightweightModeEntered, LightweightModeEntered,
ProfilesReactivated, ProfilesReactivated,
AppQuit, AppQuit,
@ -37,14 +37,25 @@ pub async fn notify_event<'a>(event: NotificationEvent<'a>) {
.into(); .into();
notify(title, body); notify(title, body);
} }
NotificationEvent::SystemProxyToggled => { NotificationEvent::SystemProxyToggled(enabled) => {
let title = clash_verge_i18n::t!("notifications.systemProxyToggled.title"); let title = clash_verge_i18n::t!("notifications.systemProxyToggled.title");
let body = clash_verge_i18n::t!("notifications.systemProxyToggled.body"); let key = if enabled {
"notifications.systemProxyToggled.on"
} else {
"notifications.systemProxyToggled.off"
};
let body = clash_verge_i18n::t!(key);
notify(title, body); notify(title, body);
} }
NotificationEvent::TunModeToggled => { NotificationEvent::TunModeToggled(enabled) => {
let title = clash_verge_i18n::t!("notifications.tunModeToggled.title"); let title = clash_verge_i18n::t!("notifications.tunModeToggled.title");
let body = clash_verge_i18n::t!("notifications.tunModeToggled.body"); let key = if enabled {
"notifications.tunModeToggled.on"
} else {
"notifications.tunModeToggled.off"
};
let body = clash_verge_i18n::t!(key);
notify(title, body); notify(title, body);
} }
NotificationEvent::LightweightModeEntered => { NotificationEvent::LightweightModeEntered => {