mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-01-29 17:15:38 +08:00
chore: rename method
This commit is contained in:
@@ -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(())
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user