fix: shortcut window display issue

This commit is contained in:
Memory 2025-10-08 14:41:35 +08:00 committed by GitHub
parent 96ef2d2bbc
commit d8fdbebc4b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 9 additions and 5 deletions

View File

@ -433,15 +433,19 @@ export async function createWindow(): Promise<void> {
} }
} }
export function triggerMainWindow(): void { export function triggerMainWindow(force?: boolean): void {
if (mainWindow) { if (mainWindow) {
getAppConfig() getAppConfig()
.then(({ triggerMainWindowBehavior = 'show' }) => { .then(({ triggerMainWindowBehavior = 'toggle' }) => {
if (triggerMainWindowBehavior === 'toggle' && mainWindow?.isVisible()) { if (force === true || triggerMainWindowBehavior === 'toggle') {
if (mainWindow?.isVisible()) {
closeMainWindow() closeMainWindow()
} else { } else {
showMainWindow() showMainWindow()
} }
} else {
showMainWindow()
}
}) })
.catch(showMainWindow) .catch(showMainWindow)
} }

View File

@ -27,7 +27,7 @@ export async function registerShortcut(
switch (action) { switch (action) {
case 'showWindowShortcut': { case 'showWindowShortcut': {
return globalShortcut.register(newShortcut, () => { return globalShortcut.register(newShortcut, () => {
triggerMainWindow() triggerMainWindow(true)
}) })
} }
case 'showFloatingWindowShortcut': { case 'showFloatingWindowShortcut': {