diff --git a/src-tauri/src/conf.rs b/src-tauri/src/conf.rs
index 56e0439..079b63b 100644
--- a/src-tauri/src/conf.rs
+++ b/src-tauri/src/conf.rs
@@ -34,6 +34,8 @@ pub_struct!(AppConf {
// macOS and Windows: light / dark / system
theme: String,
// auto update policy: prompt / silent / disable
+ isinit: bool,
+ main_close: bool,
auto_update: String,
tray: bool,
popup_search: bool,
@@ -58,6 +60,8 @@ impl AppConf {
auto_update: "prompt".into(),
tray: true,
popup_search: false,
+ isinit: true,
+ main_close: false,
stay_on_top: false,
main_dashboard: false,
tray_dashboard: false,
diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs
index e7a9a11..0ebfc35 100644
--- a/src-tauri/src/main.rs
+++ b/src-tauri/src/main.rs
@@ -91,13 +91,34 @@ async fn main() {
builder
.on_menu_event(menu::menu_handler)
.on_system_tray_event(menu::tray_handler)
- .on_window_event(|event| {
+ .on_window_event(move |event| {
if let tauri::WindowEvent::CloseRequested { api, .. } = event.event() {
- let win = event.window();
+ let win = event.window().clone();
+ let app_conf = AppConf::read();
if win.label() == "core" {
- event.window().minimize().unwrap();
+ if app_conf.isinit {
+ tauri::api::dialog::ask(
+ Some(event.window()),
+ "",
+ "Do you want to exit the application when you click the [x] button?",
+ move |is_ok| {
+ app_conf
+ .amend(serde_json::json!({ "isinit" : false, "main_close": is_ok }))
+ .write();
+ if is_ok {
+ std::process::exit(0);
+ } else {
+ win.minimize().unwrap();
+ }
+ },
+ );
+ } else if app_conf.main_close {
+ std::process::exit(0);
+ } else {
+ win.minimize().unwrap();
+ }
} else {
- win.close().unwrap();
+ event.window().close().unwrap();
}
api.prevent_close();
}
diff --git a/src/view/settings/MainWindow.tsx b/src/view/settings/MainWindow.tsx
index d940b07..5a3adbf 100644
--- a/src/view/settings/MainWindow.tsx
+++ b/src/view/settings/MainWindow.tsx
@@ -30,12 +30,26 @@ const PopupSearchLabel = () => {
);
};
+const MainCloseLabel = () => {
+ return (
+
+ Close Exit{' '}
+