basic system tray functionality

This commit is contained in:
Joseph Montanaro
2022-12-21 14:49:01 -08:00
parent 50f0985f4f
commit 5ffa55c03c
9 changed files with 136 additions and 14 deletions

View File

@ -11,6 +11,7 @@ mod clientinfo;
mod ipc;
mod state;
mod server;
mod tray;
use state::AppState;
@ -23,6 +24,8 @@ fn main() {
tauri::Builder::default()
.manage(initial_state)
.system_tray(tray::create())
.on_system_tray_event(tray::handle_event)
.invoke_handler(tauri::generate_handler![
ipc::unlock,
ipc::respond,
@ -36,6 +39,16 @@ fn main() {
tauri::async_runtime::spawn(server::serve(addr, app.handle()));
Ok(())
})
.run(tauri::generate_context!())
.expect("error while running tauri application");
.build(tauri::generate_context!())
.expect("error while running tauri application")
.run(|app, run_event| match run_event {
tauri::RunEvent::WindowEvent { label, event, .. } => match event {
tauri::WindowEvent::CloseRequested { api, .. } => {
let _ = app.get_window(&label).map(|w| w.hide());
api.prevent_close();
}
_ => ()
}
_ => ()
})
}