fix(tray): correct spelling of 'TrayMenu' in TrayAction enum and usage

This commit is contained in:
Tunglies 2026-01-29 19:44:24 +08:00
parent b17dd39f31
commit 95281632a1
No known key found for this signature in database
GPG Key ID: B9B01B389469B3E8
2 changed files with 6 additions and 3 deletions

View File

@ -55,7 +55,7 @@ pub(crate) enum TrayAction {
SystemProxy, SystemProxy,
TunMode, TunMode,
MainWindow, MainWindow,
TrayMenue, TrayMenu,
Unknown, Unknown,
} }
@ -65,7 +65,7 @@ impl From<&str> for TrayAction {
"system_proxy" => Self::SystemProxy, "system_proxy" => Self::SystemProxy,
"tun_mode" => Self::TunMode, "tun_mode" => Self::TunMode,
"main_window" => Self::MainWindow, "main_window" => Self::MainWindow,
"tray_menue" => Self::TrayMenue, "tray_menu" => Self::TrayMenu,
_ => Self::Unknown, _ => Self::Unknown,
} }
} }

View File

@ -190,7 +190,7 @@ impl Tray {
.tray_by_id("main") .tray_by_id("main")
.ok_or_else(|| anyhow::anyhow!("Failed to get main tray"))?; .ok_or_else(|| anyhow::anyhow!("Failed to get main tray"))?;
match tray_event { match tray_event {
TrayAction::TrayMenue => tray.set_show_menu_on_left_click(true)?, TrayAction::TrayMenu => tray.set_show_menu_on_left_click(true)?,
_ => tray.set_show_menu_on_left_click(false)?, _ => tray.set_show_menu_on_left_click(false)?,
} }
Ok(()) Ok(())
@ -418,6 +418,9 @@ impl Tray {
let tray_action = TrayAction::from(tray_event.as_str()); let tray_action = TrayAction::from(tray_event.as_str());
tray.on_tray_icon_event(move |_app_handle, event| { tray.on_tray_icon_event(move |_app_handle, event| {
if matches!(tray_action, TrayAction::Unknown) {
return;
}
if let TrayIconEvent::Click { if let TrayIconEvent::Click {
button: MouseButton::Left, button: MouseButton::Left,
button_state: MouseButtonState::Down, button_state: MouseButtonState::Down,