chore: rename method

This commit is contained in:
huzibaca
2024-09-22 20:29:43 +08:00
parent 2cdf33d8a1
commit 2263ade187
2 changed files with 9 additions and 5 deletions

View File

@@ -10,7 +10,7 @@ use crate::{
use anyhow::Result;
use tauri::{
menu::CheckMenuItem,
tray::{MouseButton, MouseButtonState, TrayIconEvent},
tray::{MouseButton, MouseButtonState, TrayIconEvent, TrayIconId},
};
use tauri::{
menu::{MenuEvent, MenuItem, PredefinedMenuItem, Submenu},
@@ -20,8 +20,9 @@ use tauri::{AppHandle, Manager};
pub struct Tray {}
impl Tray {
pub fn update_systray(app_handle: &AppHandle) -> Result<()> {
let tray = app_handle.tray_by_id("main").unwrap();
pub fn create_systray(app_handle: &AppHandle) -> Result<()> {
let tray_incon_id = TrayIconId::new("main");
let tray = app_handle.tray_by_id(&tray_incon_id).unwrap();
tray.on_tray_icon_event(|tray, event| {
let tray_event = { Config::verge().latest().tray_event.clone() };
@@ -50,6 +51,8 @@ impl Tray {
..
} = event
{
let _ = tray.set_visible(false);
let app = tray.app_handle();
match tray_event.as_str() {
"system_proxy" => feat::toggle_system_proxy(),
@@ -57,10 +60,11 @@ impl Tray {
"main_window" => resolve::create_window(app),
_ => {}
}
let _ = tray.set_visible(true);
}
});
println!("{:?}", tray.id());
tray.on_menu_event(on_menu_event);
Ok(())
}