mirror of
https://github.com/h3poteto/whalebird-desktop
synced 2025-02-01 01:47:01 +01:00
Merge pull request #1042 from h3poteto/iss-1030
closes #1030 Do not enforce single instance in darwin
This commit is contained in:
commit
cf18d3f595
4
Makefile
4
Makefile
@ -14,6 +14,10 @@ mac:
|
||||
npm run package:mac
|
||||
mv build/Whalebird-${VERSION}-mac.dmg build/Whalebird-${VERSION}-darwin-x64.dmg
|
||||
|
||||
mas:
|
||||
npm run build:mas
|
||||
./appStore.sh
|
||||
|
||||
linux:
|
||||
npm run package:linux
|
||||
mv build/Whalebird-${VERSION}-linux-amd64.deb build/Whalebird-${VERSION}-linux-x64.deb
|
||||
|
@ -74,23 +74,28 @@ let mainWindow: BrowserWindow | null
|
||||
let tray: Tray | null
|
||||
const winURL = process.env.NODE_ENV === 'development' ? `http://localhost:9080` : `file://${__dirname}/index.html`
|
||||
|
||||
// Enforces single instance for linux and windows.
|
||||
const gotTheLock = app.requestSingleInstanceLock()
|
||||
// MAS build is not allowed requestSingleInstanceLock.
|
||||
// ref: https://github.com/h3poteto/whalebird-desktop/issues/1030
|
||||
// ref: https://github.com/electron/electron-osx-sign/issues/137#issuecomment-307626305
|
||||
if (process.platform !== 'darwin') {
|
||||
// Enforces single instance for linux and windows.
|
||||
const gotTheLock = app.requestSingleInstanceLock()
|
||||
|
||||
if (!gotTheLock) {
|
||||
app.quit()
|
||||
} else {
|
||||
app.on('second-instance', () => {
|
||||
// Someone tried to run a second instance, we should focus our window.
|
||||
if (mainWindow) {
|
||||
if (mainWindow.isMinimized()) mainWindow.restore()
|
||||
if (!mainWindow!.isVisible()) {
|
||||
mainWindow!.show()
|
||||
mainWindow!.setSkipTaskbar(false)
|
||||
if (!gotTheLock) {
|
||||
app.quit()
|
||||
} else {
|
||||
app.on('second-instance', () => {
|
||||
// Someone tried to run a second instance, we should focus our window.
|
||||
if (mainWindow) {
|
||||
if (mainWindow.isMinimized()) mainWindow.restore()
|
||||
if (!mainWindow!.isVisible()) {
|
||||
mainWindow!.show()
|
||||
mainWindow!.setSkipTaskbar(false)
|
||||
}
|
||||
mainWindow.focus()
|
||||
}
|
||||
mainWindow.focus()
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
const appId = pkg.build.appId
|
||||
|
Loading…
x
Reference in New Issue
Block a user