fix: windows can't start

This commit is contained in:
lencx
2022-12-28 03:33:40 +08:00
parent 631dee95a7
commit 478049e23e
8 changed files with 188 additions and 176 deletions

View File

@@ -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")]