Skip to content

Commit

Permalink
🐛 Close minimize to hide in mac
Browse files Browse the repository at this point in the history
  • Loading branch information
tw93 committed Apr 28, 2024
1 parent f0dd193 commit 7b94f5b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 25 deletions.
4 changes: 0 additions & 4 deletions script/build_with_pake_cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -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' });
Expand Down
32 changes: 11 additions & 21 deletions src-tauri/src/main.rs
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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"))]
Expand Down

0 comments on commit 7b94f5b

Please sign in to comment.