1
0
mirror of https://github.com/lencx/ChatGPT.git synced 2024-10-01 01:06:13 -04:00

chore: window

This commit is contained in:
lencx 2023-01-01 16:21:20 +08:00
parent e2235e7060
commit 4c86477d6f
3 changed files with 40 additions and 12 deletions

View File

@ -1,5 +1,10 @@
# UPDATE LOG
## v0.7.5
fix:
- close the main window and hide it in the tray (windows systems)
## v0.7.4
fix:

View File

@ -293,12 +293,13 @@ pub fn menu_handler(event: WindowMenuEvent<tauri::Wry>) {
// --- SystemTray Menu
pub fn tray_menu() -> SystemTray {
if cfg!(target_os = "macos") {
return SystemTray::new().with_menu(
SystemTray::new().with_menu(
SystemTrayMenu::new()
.add_item(CustomMenuItem::new(
"control_center".to_string(),
"Control Center",
))
.add_native_item(SystemTrayMenuItem::Separator)
.add_item(CustomMenuItem::new(
"show_dock_icon".to_string(),
"Show Dock Icon",
@ -307,20 +308,28 @@ pub fn tray_menu() -> SystemTray {
"hide_dock_icon".to_string(),
"Hide Dock Icon",
))
.add_item(CustomMenuItem::new(
"show_core".to_string(),
"Show ChatGPT",
))
.add_native_item(SystemTrayMenuItem::Separator)
.add_item(CustomMenuItem::new("quit".to_string(), "Quit ChatGPT")),
);
)
} else {
SystemTray::new().with_menu(
SystemTrayMenu::new()
.add_item(CustomMenuItem::new(
"control_center".to_string(),
"Control Center",
))
.add_item(CustomMenuItem::new(
"show_core".to_string(),
"Show ChatGPT",
))
.add_native_item(SystemTrayMenuItem::Separator)
.add_item(CustomMenuItem::new("quit".to_string(), "Quit ChatGPT")),
)
}
SystemTray::new().with_menu(
SystemTrayMenu::new()
.add_item(CustomMenuItem::new(
"control_center".to_string(),
"Control Center",
))
.add_native_item(SystemTrayMenuItem::Separator)
.add_item(CustomMenuItem::new("quit".to_string(), "Quit ChatGPT")),
)
}
// --- SystemTray Event
@ -361,6 +370,15 @@ pub fn tray_handler(handle: &AppHandle, event: SystemTrayEvent) {
.unwrap();
}
}
"show_core" => {
let core_win = app.get_window("core").unwrap();
let tray_win = app.get_window("tray").unwrap();
if !core_win.is_visible().unwrap() {
core_win.show().unwrap();
core_win.set_focus().unwrap();
tray_win.hide().unwrap();
}
}
"quit" => std::process::exit(0),
_ => (),
},

View File

@ -82,7 +82,12 @@ async fn main() {
// TODO: https://github.com/tauri-apps/tauri/issues/3084
// event.window().hide().unwrap();
// https://github.com/tauri-apps/tao/pull/517
#[cfg(target_os = "macos")]
event.window().minimize().unwrap();
// fix: https://github.com/lencx/ChatGPT/issues/93
#[cfg(not(target_os = "macos"))]
event.window().hide().unwrap();
}
api.prevent_close();
}