1. 页面既无法关闭,也无法刷新
window.onbeforeunload = (e) => {
console.log('I do not want to be closed')
// Unlike usual browsers that a message box will be prompted to users, returning
// a non-void value will silently cancel the close.
// It is recommended to use the dialog API to let the user confirm closing the
// application.
e.returnValue = false
}
2. 页面无法关闭
let canQuit = false;
mainWindow.on('close', (event) => {
if (!canQuit) {
event.preventDefault();}
});