Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed system tray icon not disappearing on exit #960

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src-tauri/src/app/menu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ pub fn tray_handler(handle: &AppHandle, event: SystemTrayEvent) {
}
};
}
"quit" => std::process::exit(0),
"quit" => app.exit(0),
_ => (),
},
_ => (),
Expand Down
6 changes: 4 additions & 2 deletions src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ mod utils;

use app::{cmd, fs_extra, gpt, menu, script, setup, window};
use conf::AppConf;
use tauri::Manager;
use tauri_plugin_autostart::MacosLauncher;
use tauri_plugin_log::{
fern::colors::{Color, ColoredLevelConfig},
Expand Down Expand Up @@ -99,6 +100,7 @@ async fn main() {
.on_system_tray_event(menu::tray_handler)
.on_window_event(move |event| {
if let tauri::WindowEvent::CloseRequested { api, .. } = event.event() {
let app_handle = event.window().app_handle().clone();
let win = event.window().clone();
let app_conf = AppConf::read();
if win.label() == "core" {
Expand All @@ -112,14 +114,14 @@ async fn main() {
.amend(serde_json::json!({ "isinit" : false, "main_close": is_ok }))
.write();
if is_ok {
std::process::exit(0);
app_handle.exit(0);
} else {
win.minimize().unwrap();
}
},
);
} else if app_conf.main_close {
std::process::exit(0);
app_handle.exit(0);
} else {
win.minimize().unwrap();
}
Expand Down
3 changes: 2 additions & 1 deletion src-tauri/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,15 @@ pub fn clear_conf(app: &tauri::AppHandle) {
Note: The application will exit automatically after the configuration cleanup!",
root.to_string_lossy()
);
let app_clone = app.clone();
tauri::api::dialog::ask(
app.get_window("core").as_ref(),
"Clear Config",
msg,
move |is_ok| {
if is_ok {
fs::remove_dir_all(root).unwrap();
std::process::exit(0);
app_clone.exit(0);
}
},
);
Expand Down