desktop 앱 적용

This commit is contained in:
Macbook
2026-06-14 10:15:54 +09:00
parent 7a2f65088c
commit 86b99d8c10
81 changed files with 8164 additions and 37 deletions
+81
View File
@@ -0,0 +1,81 @@
use tauri::{
menu::{MenuBuilder, MenuItemBuilder},
tray::{MouseButton, MouseButtonState, TrayIconBuilder, TrayIconEvent},
AppHandle, Manager, RunEvent,
};
fn show_main_window(app: &AppHandle) {
if let Some(w) = app.get_webview_window("main") {
let _ = w.show();
let _ = w.unminimize();
let _ = w.set_focus();
}
}
#[cfg_attr(mobile, tauri::mobile_entry_point)]
pub fn run() {
tauri::Builder::default()
.plugin(tauri_plugin_notification::init())
.plugin(tauri_plugin_updater::Builder::new().build())
.plugin(tauri_plugin_process::init())
.plugin(tauri_plugin_opener::init())
.setup(|app| {
let show_i = MenuItemBuilder::with_id("show", "GoldenChart 열기").build(app)?;
let quit_i = MenuItemBuilder::with_id("quit", "종료").build(app)?;
let menu = MenuBuilder::new(app)
.items(&[&show_i, &quit_i])
.build()?;
let icon = app
.default_window_icon()
.expect("missing tray icon")
.clone();
let _tray = TrayIconBuilder::new()
.icon(icon)
.menu(&menu)
.tooltip("GoldenChart")
.show_menu_on_left_click(false)
.on_menu_event(|app, event| match event.id.as_ref() {
"show" => show_main_window(app),
"quit" => app.exit(0),
_ => {}
})
.on_tray_icon_event(|tray, event| {
if let TrayIconEvent::Click {
button: MouseButton::Left,
button_state: MouseButtonState::Up,
..
} = event
{
show_main_window(tray.app_handle());
}
})
.build(app)?;
show_main_window(app.handle());
Ok(())
})
.on_window_event(|window, event| {
if window.label() != "main" {
return;
}
if let tauri::WindowEvent::CloseRequested { api, .. } = event {
api.prevent_close();
let _ = window.hide();
}
})
.build(tauri::generate_context!())
.expect("error while building tauri application")
.run(|app_handle, event| match event {
#[cfg(target_os = "macos")]
RunEvent::Reopen { .. } => show_main_window(&app_handle),
RunEvent::ExitRequested { api, .. } => {
api.prevent_exit();
if let Some(w) = app_handle.get_webview_window("main") {
let _ = w.hide();
}
}
_ => {}
});
}