electron打包成.exe后限制只启动一个应用

注意:这是2.x的文档

const {app} = require('electron')
let myWindow = null

const shouldQuit = app.makeSingleInstance((commandLine, workingDirectory) => {
  // Someone tried to run a second instance, we should focus our window.
  if (myWindow) {
    if (myWindow.isMinimized()) myWindow.restore()
    myWindow.focus()
    myWindow.show()
  }
})

if (shouldQuit) {
  app.quit()
}

// Create myWindow, load the rest of the app, etc...
app.on('ready', () => {
})
posted @ 2019-04-23 14:09  山村码农  阅读(1875)  评论(0编辑  收藏  举报