关闭我的Electron app流程继续运行。这是我的代码:
label:‘关闭’,点击(){ app.quit() }
window.on(‘close’,function(e){ var choice = require(‘electron’)。dialog ….
您正在阻止Close事件的默认行为。 (e.PreventDefault())
您不应该在关闭事件时要求用户确认。 window.on('close')事件的目的是执行清理任务,例如删除临时文件,如果窗口是父窗口则关闭其他相关进程。
你可以用这种方式编写它:
label: 'Close', click() { var choice = require('electron').dialog.showMessageBox({ type: 'question', buttons: ['Yes', 'No'], title: 'Confirm', message: 'Are you sure you want to quit?' }, (response) => { if (response == '0') { app.quit() } }) window.on('close', function (e) { window = null // Clean up your window object. })