fix: Clicking the taskbar icon while enable the Quick Assistant can't open the main window
This commit is contained in:
parent
7c4d81c108
commit
fb8ed35b59
@ -1,5 +1,5 @@
|
|||||||
import { electronApp, optimizer } from '@electron-toolkit/utils'
|
import { electronApp, optimizer } from '@electron-toolkit/utils'
|
||||||
import { app, BrowserWindow } from 'electron'
|
import { app } from 'electron'
|
||||||
import installExtension, { REDUX_DEVTOOLS } from 'electron-devtools-installer'
|
import installExtension, { REDUX_DEVTOOLS } from 'electron-devtools-installer'
|
||||||
|
|
||||||
import { registerIpc } from './ipc'
|
import { registerIpc } from './ipc'
|
||||||
@ -46,9 +46,8 @@ if (!app.requestSingleInstanceLock()) {
|
|||||||
new TrayService()
|
new TrayService()
|
||||||
|
|
||||||
app.on('activate', function () {
|
app.on('activate', function () {
|
||||||
// On macOS it's common to re-create a window in the app when the
|
const mainWindow = windowService.getMainWindow()
|
||||||
// dock icon is clicked and there are no other windows open.
|
if (!mainWindow || mainWindow.isDestroyed()) {
|
||||||
if (BrowserWindow.getAllWindows().length === 0) {
|
|
||||||
windowService.createMainWindow()
|
windowService.createMainWindow()
|
||||||
} else {
|
} else {
|
||||||
windowService.showMainWindow()
|
windowService.showMainWindow()
|
||||||
@ -68,12 +67,7 @@ if (!app.requestSingleInstanceLock()) {
|
|||||||
|
|
||||||
// Listen for second instance
|
// Listen for second instance
|
||||||
app.on('second-instance', () => {
|
app.on('second-instance', () => {
|
||||||
const mainWindow = BrowserWindow.getAllWindows()[0]
|
windowService.showMainWindow()
|
||||||
if (mainWindow) {
|
|
||||||
mainWindow.isMinimized() && mainWindow.restore()
|
|
||||||
mainWindow.show()
|
|
||||||
mainWindow.focus()
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
app.on('browser-window-created', (_, window) => {
|
app.on('browser-window-created', (_, window) => {
|
||||||
|
|||||||
@ -28,6 +28,7 @@ export class WindowService {
|
|||||||
|
|
||||||
public createMainWindow(): BrowserWindow {
|
public createMainWindow(): BrowserWindow {
|
||||||
if (this.mainWindow && !this.mainWindow.isDestroyed()) {
|
if (this.mainWindow && !this.mainWindow.isDestroyed()) {
|
||||||
|
this.mainWindow.show()
|
||||||
return this.mainWindow
|
return this.mainWindow
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -248,17 +249,32 @@ export class WindowService {
|
|||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
mainWindow.hide()
|
mainWindow.hide()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
mainWindow.on('closed', () => {
|
||||||
|
this.mainWindow = null
|
||||||
|
})
|
||||||
|
|
||||||
|
mainWindow.on('show', () => {
|
||||||
|
if (this.miniWindow && !this.miniWindow.isDestroyed()) {
|
||||||
|
this.miniWindow.hide()
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
public showMainWindow() {
|
public showMainWindow() {
|
||||||
if (this.mainWindow) {
|
if (this.miniWindow && !this.miniWindow.isDestroyed()) {
|
||||||
|
this.miniWindow.hide()
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.mainWindow && !this.mainWindow.isDestroyed()) {
|
||||||
if (this.mainWindow.isMinimized()) {
|
if (this.mainWindow.isMinimized()) {
|
||||||
return this.mainWindow.restore()
|
this.mainWindow.restore()
|
||||||
}
|
}
|
||||||
this.mainWindow.show()
|
this.mainWindow.show()
|
||||||
this.mainWindow.focus()
|
this.mainWindow.focus()
|
||||||
} else {
|
} else {
|
||||||
this.createMainWindow()
|
this.mainWindow = this.createMainWindow()
|
||||||
|
this.mainWindow.focus()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -269,7 +285,10 @@ export class WindowService {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.selectionMenuWindow) {
|
if (this.mainWindow && !this.mainWindow.isDestroyed()) {
|
||||||
|
this.mainWindow.hide()
|
||||||
|
}
|
||||||
|
if (this.selectionMenuWindow && !this.selectionMenuWindow.isDestroyed()) {
|
||||||
this.selectionMenuWindow.hide()
|
this.selectionMenuWindow.hide()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user