示例
代码
win.on("close", (event) => {
if (dialog.showMessageBoxSync(win, {
type: "info",
buttons: ["最小化到托盘", "直接退出"],
title: "提示",
message: "确定要退出吗?",
defaultId: 0,
cancelId: 1
}) === 0) {
event.preventDefault();
win.hide();
} else {
app.exit();
}
});