我有一个电子应用程序,它加载应用程序网络版本的 URL。但是,我无法通过单击 X 按钮关闭应用程序,并且我无权访问 webapp。我试过这个:
let count = BrowserWindow.getAllWindows().length;
///returns 1, so there is only 1 window)
window.onbeforeunload=function(e){
e.returnValue=undefined;
return undefined;
}
window.close();
app.quit();
什么都没发生。
app.exit(0)
有效,但我不想使用它。有没有办法可以用window.close
and关闭应用程序app.quit
?
编辑:问题是那些全局的 beforeunload 事件。如果我在 devtools 中单击删除,我可以关闭该应用程序。
这也let names= window.eventNames();
返回一个没有任何beforeunload事件的数组