我有一个消息框,当用户在dashboardWindow上单击关闭时(Windows操作系统右上角的X按钮),该消息框将打开。>
dashboardWindow.on("close", (event) => { event.preventDefault(); console.log("before message box"); dialog.showMessageBox( dashboardWindows, { message: "Test", buttons: ["Default Button", "Cancel Button"], defaultId: 0, // bound to buttons array cancelId: 1 // bound to buttons array }, (response) => { if (response === 0) { // bound to buttons array console.log("Default button clicked."); } else if (response === 1) { // bound to buttons array console.log("Cancel button clicked."); } } ); console.log("after message box"); }); }
当我关闭dashboardWindow但无法获得
response === 0
时,打开的消息框。即使没有单击按钮,Samehowconsole.log("after message box");
也已运行。如何使响应有效(messageBox上的返回索引按钮)?
我有一个消息框,当用户在dashboardWindow上单击关闭时(Windows操作系统右上角的X按钮),dashboxWindow.on(“ close”,(event)=> {event.preventDefault(); console ....
请参阅有关dialog.showMessageBox的最新API文档:此方法返回Promise对象,并且不再使用回调函数,就像在Electron v5.x.x之前一样。