From 7b94f5ba78e972ba52058f7d0b27a5ee2fa689bb Mon Sep 17 00:00:00 2001 From: Tw93 Date: Sun, 28 Apr 2024 17:46:39 +0800 Subject: [PATCH] :bug: Close minimize to hide in mac --- script/build_with_pake_cli.js | 4 ---- src-tauri/src/main.rs | 32 +++++++++++--------------------- 2 files changed, 11 insertions(+), 25 deletions(-) diff --git a/script/build_with_pake_cli.js b/script/build_with_pake_cli.js index e9273f576..fede4d0cb 100644 --- a/script/build_with_pake_cli.js +++ b/script/build_with_pake_cli.js @@ -47,10 +47,6 @@ if (process.platform === 'linux') { params = `${params} --show-system-tray`; } -if (process.platform === 'darwin') { - params = `${params} --show-menu`; -} - const downloadIcon = async iconFile => { try { const response = await axios.get(process.env.ICON, { responseType: 'arraybuffer' }); diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index 3a26f5f23..aa9eb704f 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -1,42 +1,31 @@ #![cfg_attr( - all(not(debug_assertions), target_os = "windows"), - windows_subsystem = "windows" +all(not(debug_assertions), target_os = "windows"), +windows_subsystem = "windows" )] mod app; mod util; -use app::{invoke, menu, window}; +use app::{invoke, window, menu}; use invoke::{download_file, download_file_by_binary}; -use menu::{get_menu, menu_event_handle}; +use menu::{get_system_tray, system_tray_handle}; use tauri_plugin_window_state::Builder as windowStatePlugin; use util::{get_data_dir, get_pake_config}; use window::get_window; pub fn run_app() { let (pake_config, tauri_config) = get_pake_config(); - let show_menu = pake_config.show_menu(); - let menu = get_menu(); let data_dir = get_data_dir(tauri_config); let mut tauri_app = tauri::Builder::default(); - if show_menu { - tauri_app = tauri_app.menu(menu).on_menu_event(menu_event_handle); - } - - #[cfg(not(target_os = "macos"))] - { - use menu::{get_system_tray, system_tray_handle}; - - let show_system_tray = pake_config.show_system_tray(); - let system_tray = get_system_tray(show_menu); + let show_system_tray = pake_config.show_system_tray(); + let system_tray = get_system_tray(); - if show_system_tray { - tauri_app = tauri_app - .system_tray(system_tray) - .on_system_tray_event(system_tray_handle); - } + if show_system_tray { + tauri_app = tauri_app + .system_tray(system_tray) + .on_system_tray_event(system_tray_handle); } tauri_app @@ -57,6 +46,7 @@ pub fn run_app() { #[cfg(target_os = "macos")] { event.window().minimize().unwrap(); + event.window().hide().unwrap(); } #[cfg(not(target_os = "macos"))]