首页 文章

如何退出Mac上的Electron应用程序?

提问于
浏览
1

以下是Electron网站(https://electron.atom.io/docs/tutorial/quick-start/)的股票代码:

app.on('window-all-closed', () => {
  if (process.platform !== 'darwin') {
    app.quit()
  }
})

在Mac OS 10.12.4上,当调用上述内容时,它不会关闭应用程序 . 只有窗口 . 在条件上方添加 app.quit() 可以关闭应用程序 . 他们是否留下了特定于Mac OS X的内容,阻止了应用关闭?

1 回答

  • 9

    您将需要学习如何阅读代码中的注释 . 以下是您链接的页面的完整摘录:

    // Quit when all windows are closed.
    app.on('window-all-closed', () => {
      // On macOS it is common for applications and their menu bar
      // to stay active until the user quits explicitly with Cmd + Q
      if (process.platform !== 'darwin') {
        app.quit()
      }
    })
    

    if语句上面的两行与if语句相关 . 这基本上说我们退出macOS上的应用程序,因为这是其他应用程序中常见的功能 .

相关问题