docs: modify the showMessageBox method to showMessageBoxSync (#22080)

In handling the will-prevent-unload event, preventDefault should be executed synchronously, and here should also be showMessageBoxSync
This commit is contained in:
CoderPoet 2020-02-10 16:12:30 +08:00 committed by GitHub
parent d5e7904610
commit 97cf24ac98

View file

@ -310,7 +310,7 @@ and allow the page to be unloaded.
const { BrowserWindow, dialog } = require('electron')
const win = new BrowserWindow({ width: 800, height: 600 })
win.webContents.on('will-prevent-unload', (event) => {
const choice = dialog.showMessageBox(win, {
const choice = dialog.showMessageBoxSync(win, {
type: 'question',
buttons: ['Leave', 'Stay'],
title: 'Do you want to leave this site?',