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:
parent
d5e7904610
commit
97cf24ac98
1 changed files with 1 additions and 1 deletions
|
@ -310,7 +310,7 @@ and allow the page to be unloaded.
|
||||||
const { BrowserWindow, dialog } = require('electron')
|
const { BrowserWindow, dialog } = require('electron')
|
||||||
const win = new BrowserWindow({ width: 800, height: 600 })
|
const win = new BrowserWindow({ width: 800, height: 600 })
|
||||||
win.webContents.on('will-prevent-unload', (event) => {
|
win.webContents.on('will-prevent-unload', (event) => {
|
||||||
const choice = dialog.showMessageBox(win, {
|
const choice = dialog.showMessageBoxSync(win, {
|
||||||
type: 'question',
|
type: 'question',
|
||||||
buttons: ['Leave', 'Stay'],
|
buttons: ['Leave', 'Stay'],
|
||||||
title: 'Do you want to leave this site?',
|
title: 'Do you want to leave this site?',
|
||||||
|
|
Loading…
Reference in a new issue