feat(electron): Add close pop-up confirmation (#157)

* Update ipcMain.js

Add close pop-up confirmation

* Update ipcMain.js

Judging MacOS
master
TestGifts 4 years ago committed by GitHub
parent d6be72f5ce
commit 0ef108df4c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -24,12 +24,34 @@ export function initIpcMain(win, store) {
event.returnValue = null;
});
});
ipcMain.on("close", () => {
win.hide();
// win.close();
// app.quit();
ipcMain.on('close', (e) => {
if (process.platform == 'darwin') {
//判断mac
win.hide();
})
e.preventDefault()//阻止默认行为
dialog.showMessageBox({
type: 'info',
title: 'Information',
cancelId:2,
defaultId: 0,
message: '确定要关闭吗?',
buttons: ['最小化','直接退出']
}).then(result => {
if (result.response == 0) {
e.preventDefault(); //阻止默认行为
win.minimize(); //调用 最小化实例方法
} else if(result.response == 1) {
win = null;
//app.quit();
app.exit(); //exit()直接关闭客户端不会执行quit();
}
}).catch(err => {
console.log(err)
})
});
ipcMain.on("minimize", () => {
win.minimize();

Loading…
Cancel
Save