mirror of
https://github.com/FranP-code/ChatGPT.git
synced 2025-10-13 00:13:25 +00:00
fix: windows can't start
This commit is contained in:
@@ -3,11 +3,14 @@ use crate::{
|
||||
utils,
|
||||
};
|
||||
use tauri::{
|
||||
AboutMetadata, AppHandle, CustomMenuItem, Manager, Menu, MenuItem, Submenu, SystemTray,
|
||||
SystemTrayEvent, SystemTrayMenu, SystemTrayMenuItem, WindowMenuEvent,
|
||||
AppHandle, CustomMenuItem, Manager, Menu, MenuItem, Submenu, SystemTray, SystemTrayEvent,
|
||||
SystemTrayMenu, SystemTrayMenuItem, WindowMenuEvent,
|
||||
};
|
||||
use tauri_plugin_positioner::{on_tray_event, Position, WindowExt};
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
use tauri::AboutMetadata;
|
||||
|
||||
use super::window;
|
||||
|
||||
// --- Menu
|
||||
@@ -20,15 +23,15 @@ pub fn init() -> Menu {
|
||||
#[cfg(target_os = "macos")]
|
||||
MenuItem::About(name.into(), AboutMetadata::default()).into(),
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
CustomMenuItem::new("about".to_string(), "About ChatGPT")
|
||||
.into(),
|
||||
CustomMenuItem::new("about".to_string(), "About ChatGPT").into(),
|
||||
MenuItem::Services.into(),
|
||||
MenuItem::Hide.into(),
|
||||
MenuItem::HideOthers.into(),
|
||||
MenuItem::ShowAll.into(),
|
||||
MenuItem::Separator.into(),
|
||||
MenuItem::Quit.into(),
|
||||
]));
|
||||
]),
|
||||
);
|
||||
|
||||
let stay_on_top =
|
||||
CustomMenuItem::new("stay_on_top".to_string(), "Stay On Top").accelerator("CmdOrCtrl+T");
|
||||
@@ -183,7 +186,11 @@ pub fn menu_handler(event: WindowMenuEvent<tauri::Wry>) {
|
||||
// App
|
||||
"about" => {
|
||||
let tauri_conf = utils::get_tauri_conf().unwrap();
|
||||
tauri::api::dialog::message(app.get_window("core").as_ref(), "ChatGPT", format!("Version {}", tauri_conf.package.version.unwrap()));
|
||||
tauri::api::dialog::message(
|
||||
app.get_window("core").as_ref(),
|
||||
"ChatGPT",
|
||||
format!("Version {}", tauri_conf.package.version.unwrap()),
|
||||
);
|
||||
}
|
||||
// Preferences
|
||||
"control_center" => window::control_window(&app),
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use crate::{app::window, conf::ChatConfJson, utils};
|
||||
use log::info;
|
||||
use tauri::{utils::config::WindowUrl, window::WindowBuilder, App, GlobalShortcutManager, Manager};
|
||||
use tauri::{utils::config::WindowUrl, window::WindowBuilder, App, Manager};
|
||||
|
||||
pub fn init(app: &mut App) -> std::result::Result<(), Box<dyn std::error::Error>> {
|
||||
let chat_conf = ChatConfJson::get_chat_conf();
|
||||
@@ -14,28 +14,29 @@ pub fn init(app: &mut App) -> std::result::Result<(), Box<dyn std::error::Error>
|
||||
|
||||
info!("stepup");
|
||||
|
||||
{
|
||||
info!("global_shortcut_start");
|
||||
let handle = app.app_handle();
|
||||
let mut shortcut = app.global_shortcut_manager();
|
||||
let is_mini_key = shortcut.is_registered("CmdOrCtrl+Shift+O");
|
||||
// fix: Global shortcuts can cause programs to exit under windows
|
||||
// {
|
||||
// info!("global_shortcut_start");
|
||||
// let handle = app.app_handle();
|
||||
// let mut shortcut = app.global_shortcut_manager();
|
||||
// let is_mini_key = shortcut.is_registered("CmdOrCtrl+Shift+O");
|
||||
|
||||
if is_mini_key.is_ok() {
|
||||
shortcut
|
||||
.register("CmdOrCtrl+Shift+O", move || {
|
||||
if let Some(w) = handle.get_window("core") {
|
||||
if w.is_visible().unwrap() {
|
||||
w.hide().unwrap();
|
||||
} else {
|
||||
w.show().unwrap();
|
||||
w.set_focus().unwrap();
|
||||
}
|
||||
}
|
||||
})
|
||||
.unwrap();
|
||||
};
|
||||
info!("global_shortcut_end");
|
||||
}
|
||||
// if is_mini_key.is_ok() {
|
||||
// shortcut
|
||||
// .register("CmdOrCtrl+Shift+O", move || {
|
||||
// if let Some(w) = handle.get_window("core") {
|
||||
// if w.is_visible().unwrap() {
|
||||
// w.hide().unwrap();
|
||||
// } else {
|
||||
// w.show().unwrap();
|
||||
// w.set_focus().unwrap();
|
||||
// }
|
||||
// }
|
||||
// })
|
||||
// .unwrap();
|
||||
// };
|
||||
// info!("global_shortcut_end");
|
||||
// }
|
||||
|
||||
if chat_conf.hide_dock_icon {
|
||||
#[cfg(target_os = "macos")]
|
||||
|
||||
@@ -8,7 +8,7 @@ use std::{
|
||||
path::{Path, PathBuf},
|
||||
process::Command,
|
||||
};
|
||||
use tauri::{Manager, utils::config::Config};
|
||||
use tauri::{utils::config::Config, Manager};
|
||||
|
||||
pub fn chat_root() -> PathBuf {
|
||||
tauri::api::path::home_dir().unwrap().join(".chatgpt")
|
||||
|
||||
Reference in New Issue
Block a user