Add system tray support (#166)
* Added sytem tray with hide/show buttons * Split tray into separate module * Fix persistent console window * Show/hide window on tray icon click --------- Co-authored-by: serxka <serxka@protonmail.com> Co-authored-by: Milo <40355097+serxka@users.noreply.github.com> Co-authored-by: greentore <117551249+greentore@users.noreply.github.com>
This commit is contained in:
@@ -1,18 +1,32 @@
|
||||
#![cfg_attr(
|
||||
all(not(debug_assertions), target_os = "windows"),
|
||||
windows_subsystem = "windows"
|
||||
all(not(debug_assertions), target_os = "windows"),
|
||||
windows_subsystem = "windows"
|
||||
)]
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
mod menu;
|
||||
mod tray;
|
||||
|
||||
fn main() {
|
||||
let builder = tauri::Builder::default();
|
||||
let builder = tauri::Builder::default();
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
let builder = builder.menu(menu::menu());
|
||||
#[cfg(target_os = "macos")]
|
||||
let builder = builder.menu(menu::menu());
|
||||
|
||||
builder
|
||||
.run(tauri::generate_context!())
|
||||
.expect("error while running tauri application");
|
||||
}
|
||||
let builder = builder
|
||||
.system_tray(tray::system_tray())
|
||||
.on_system_tray_event(tray::system_tray_handler);
|
||||
|
||||
builder
|
||||
.build(tauri::generate_context!())
|
||||
.expect("error while building tauri application")
|
||||
.run(run_event_handler)
|
||||
}
|
||||
|
||||
fn run_event_handler<R: tauri::Runtime>(app: &tauri::AppHandle<R>, event: tauri::RunEvent) {
|
||||
match event {
|
||||
tauri::RunEvent::WindowEvent { label, event, .. } => {
|
||||
tray::window_event_handler(app, &label, &event);
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user