chore: try adjusting the triggering of the tray mouse button

This commit is contained in:
huzibaca 2024-09-21 15:38:14 +08:00
parent 424c1f7d8f
commit e92074e586
No known key found for this signature in database
GPG Key ID: D4364EE4851DC302

View File

@ -22,9 +22,29 @@ pub struct Tray {}
impl Tray {
pub fn update_systray(app_handle: &AppHandle) -> Result<()> {
let tray = app_handle.tray_by_id("main").unwrap();
#[cfg(not(target_os = "macos"))]
let _ = tray.set_show_menu_on_left_click(false);
tray.on_tray_icon_event(|tray, event| {
let tray_event = { Config::verge().latest().tray_event.clone() };
let tray_event: String = tray_event.unwrap_or("main_window".into());
#[cfg(target_os = "macos")]
if let TrayIconEvent::Click {
button: MouseButton::Right,
..
} = event
{
let app = tray.app_handle();
match tray_event.as_str() {
"system_proxy" => feat::toggle_system_proxy(),
"tun_mode" => feat::toggle_tun_mode(),
"main_window" => resolve::create_window(app),
_ => {}
}
}
#[cfg(not(target_os = "macos"))]
if let TrayIconEvent::Click {
button: MouseButton::Left,
..