Fixed the bug that the quick search window can still be called up by using shortcut keys when quick search is disabled.

This commit is contained in:
fanchenio 2023-11-09 09:55:10 +08:00
parent e688210a58
commit 5173d73b42

View File

@ -75,32 +75,50 @@ function setShortcutKey(setting: Setting = global.setting) {
setting.general.showHideShortcutKey &&
setting.general.showHideShortcutKey.trim() !== ""
) {
globalShortcut.register(setting.general.showHideShortcutKey, () => {
if (global.mainWindow.isVisible()) {
hideMainWindow();
} else {
showMainWindowBefore(true);
try {
globalShortcut.register(setting.general.showHideShortcutKey, () => {
if (global.mainWindow.isVisible()) {
hideMainWindow();
} else {
showMainWindowBefore(true);
}
});
} catch (e) {
if (process.env.NODE_ENV === "development") {
console.log(e);
}
});
}
}
// 分类快捷键
let classificationList = selectClassificationList();
for (const classification of classificationList) {
if (classification.globalShortcutKey && classification.shortcutKey) {
globalShortcut.register(classification.shortcutKey, () => {
// 分类
showMainWindowBefore(true, classification.id);
});
try {
globalShortcut.register(classification.shortcutKey, () => {
// 分类
showMainWindowBefore(true, classification.id);
});
} catch (e) {
if (process.env.NODE_ENV === "development") {
console.log(e);
}
}
}
}
// 项目快捷键
let itemList = selectItemList();
for (const item of itemList) {
if (item.globalShortcutKey && item.shortcutKey) {
globalShortcut.register(item.shortcutKey, () => {
// 项目
run("main", "open", item);
});
try {
globalShortcut.register(item.shortcutKey, () => {
// 项目
run("main", "open", item);
});
} catch (e) {
if (process.env.NODE_ENV === "development") {
console.log(e);
}
}
}
}
// 快速搜索
@ -108,24 +126,35 @@ function setShortcutKey(setting: Setting = global.setting) {
setting.quickSearch.showHideShortcutKey &&
setting.quickSearch.showHideShortcutKey.trim() !== ""
) {
globalShortcut.register(setting.quickSearch.showHideShortcutKey, () => {
// 如果窗口不存在或者被销毁的话,就创建窗口
if (!global.quickSearchWindow || global.quickSearchWindow.isDestroyed()) {
createQuickSearchWindow();
}
// 如果初始化完毕并且窗口状态是正常的话,可以进行显示/隐藏
if (
global.quickSearchWindowInit &&
global.quickSearchWindow &&
!global.quickSearchWindow.isDestroyed()
) {
if (global.quickSearchWindow.isVisible()) {
hideQuickSearchWindow();
} else {
showQuickSearchWindowBefore();
try {
globalShortcut.register(setting.quickSearch.showHideShortcutKey, () => {
if (global.setting.quickSearch.enable) {
// 如果窗口不存在或者被销毁的话,就创建窗口
if (
!global.quickSearchWindow ||
global.quickSearchWindow.isDestroyed()
) {
createQuickSearchWindow();
}
// 如果初始化完毕并且窗口状态是正常的话,可以进行显示/隐藏
if (
global.quickSearchWindowInit &&
global.quickSearchWindow &&
!global.quickSearchWindow.isDestroyed()
) {
if (global.quickSearchWindow.isVisible()) {
hideQuickSearchWindow();
} else {
showQuickSearchWindowBefore();
}
}
}
});
} catch (e) {
if (process.env.NODE_ENV === "development") {
console.log(e);
}
});
}
}
}