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', () => {
})

转载于:https://www.cnblogs.com/ybixian/p/10756061.html

你可能感兴趣的:(electron打包成.exe后限制只启动一个应用)