electron 单例模式启动
// 运行方式一: 多例
// app.on('ready', () => {
//   // if (process.env.NODE_ENV === 'production') autoUpdater.checkForUpdates()
//   // autoUpdater.checkForUpdates()
// })
// 运行方式二: 单例
const gotTheLock = app.requestSingleInstanceLock()
if (!gotTheLock) {
  app.quit()
} else {
  app.on('second-instance', (event, commandLine, workingDirectory) => {
    // 当运行第二个实例时,将会聚焦到mainWindow这个窗口
    if (mainWindow) {
      if (mainWindow.isMinimized()) mainWindow.restore()
      mainWindow.focus()
      mainWindow.show()
    }
  })
}
上一篇
下一篇