Skip to content

Commit

Permalink
fix: 🐛 MacOS reduced to the tray to evoke failure
Browse files Browse the repository at this point in the history
  • Loading branch information
viarotel committed Nov 3, 2023
1 parent bd36dd3 commit d7bf83b
Showing 1 changed file with 16 additions and 19 deletions.
35 changes: 16 additions & 19 deletions electron/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,25 +94,6 @@ function createWindow() {
events(mainWindow)
}

app.on('window-all-closed', () => {
app.quit()
mainWindow = null
})

// 仅 macOS 有这个事件
app.on('activate', () => {
if (BrowserWindow.getAllWindows().length === 0) {
createWindow()
}

if (!app.dock.isVisible()) {
app.dock.show()
}

app.show()
app.focus()
})

app.whenReady().then(() => {
electronApp.setAppUserModelId('com.viarotel.escrcpy')

Expand All @@ -121,4 +102,20 @@ app.whenReady().then(() => {
})

createWindow()

// macOS 中应用被激活
app.on('activate', () => {
if (BrowserWindow.getAllWindows().length === 0) {
createWindow()
return
}

app.dock.show()
mainWindow.show()
})
})

app.on('window-all-closed', () => {
app.quit()
mainWindow = null
})

0 comments on commit d7bf83b

Please sign in to comment.