use crate::backend::PlatformTrayOps;
use crate::config::TrayConfig;
use crate::error::{TrayError, TrayResult};
use crate::event::TrayEvent;
use crate::icon::TrayIcon;
use crate::menu::Menu;
use tokio::sync::broadcast;
pub struct PlatformTray {
event_tx: broadcast::Sender<TrayEvent>,
}
impl PlatformTrayOps for PlatformTray {
fn new(_config: &TrayConfig, event_tx: broadcast::Sender<TrayEvent>) -> TrayResult<Self> {
let _ = event_tx.send(TrayEvent::Ready);
Ok(Self { event_tx })
}
fn set_icon(&self, _icon: &TrayIcon) -> TrayResult<()> {
Err(TrayError::Unsupported(
"当前平台不支持系统托盘".into()
))
}
fn set_tooltip(&self, _tooltip: &str) -> TrayResult<()> {
Err(TrayError::Unsupported(
"当前平台不支持系统托盘".into()
))
}
fn set_menu(&self, _menu: &Menu) -> TrayResult<()> {
Err(TrayError::Unsupported(
"当前平台不支持系统托盘".into()
))
}
fn destroy(&self) -> TrayResult<()> {
let _ = self.event_tx.send(TrayEvent::Destroyed);
Ok(())
}
}