mirror of
https://github.com/FranP-code/ChatGPT.git
synced 2025-10-13 00:13:25 +00:00
fix: close (#349)
This commit is contained in:
@@ -34,6 +34,8 @@ pub_struct!(AppConf {
|
|||||||
// macOS and Windows: light / dark / system
|
// macOS and Windows: light / dark / system
|
||||||
theme: String,
|
theme: String,
|
||||||
// auto update policy: prompt / silent / disable
|
// auto update policy: prompt / silent / disable
|
||||||
|
isinit: bool,
|
||||||
|
main_close: bool,
|
||||||
auto_update: String,
|
auto_update: String,
|
||||||
tray: bool,
|
tray: bool,
|
||||||
popup_search: bool,
|
popup_search: bool,
|
||||||
@@ -58,6 +60,8 @@ impl AppConf {
|
|||||||
auto_update: "prompt".into(),
|
auto_update: "prompt".into(),
|
||||||
tray: true,
|
tray: true,
|
||||||
popup_search: false,
|
popup_search: false,
|
||||||
|
isinit: true,
|
||||||
|
main_close: false,
|
||||||
stay_on_top: false,
|
stay_on_top: false,
|
||||||
main_dashboard: false,
|
main_dashboard: false,
|
||||||
tray_dashboard: false,
|
tray_dashboard: false,
|
||||||
|
|||||||
@@ -91,13 +91,34 @@ async fn main() {
|
|||||||
builder
|
builder
|
||||||
.on_menu_event(menu::menu_handler)
|
.on_menu_event(menu::menu_handler)
|
||||||
.on_system_tray_event(menu::tray_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() {
|
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" {
|
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 {
|
} else {
|
||||||
win.close().unwrap();
|
event.window().close().unwrap();
|
||||||
}
|
}
|
||||||
api.prevent_close();
|
api.prevent_close();
|
||||||
}
|
}
|
||||||
|
|||||||
14
src/view/settings/MainWindow.tsx
vendored
14
src/view/settings/MainWindow.tsx
vendored
@@ -30,12 +30,26 @@ const PopupSearchLabel = () => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const MainCloseLabel = () => {
|
||||||
|
return (
|
||||||
|
<span>
|
||||||
|
Close Exit{' '}
|
||||||
|
<Tooltip title="Click the close button whether to exit directly, the default minimized.">
|
||||||
|
<QuestionCircleOutlined style={{ color: '#1677ff' }} />
|
||||||
|
</Tooltip>
|
||||||
|
</span>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
export default function MainWindow() {
|
export default function MainWindow() {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Form.Item label={<PopupSearchLabel />} name="popup_search" valuePropName="checked">
|
<Form.Item label={<PopupSearchLabel />} name="popup_search" valuePropName="checked">
|
||||||
<Switch />
|
<Switch />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
|
<Form.Item label={<MainCloseLabel />} name="main_close" valuePropName="checked">
|
||||||
|
<Switch />
|
||||||
|
</Form.Item>
|
||||||
<SwitchOrigin name="main" />
|
<SwitchOrigin name="main" />
|
||||||
<Form.Item label="User Agent (Main)" name="ua_window">
|
<Form.Item label="User Agent (Main)" name="ua_window">
|
||||||
<Input.TextArea
|
<Input.TextArea
|
||||||
|
|||||||
Reference in New Issue
Block a user