Implement window.alert/confirm/close in main process
This commit is contained in:
parent
f894da13b0
commit
635c909aab
2 changed files with 56 additions and 37 deletions
|
@ -416,3 +416,34 @@ ipcMain.on('ELECTRON_BROWSER_SEND_TO', function (event, sendToAll, webContentsId
|
|||
contents.send(channel, ...args)
|
||||
}
|
||||
})
|
||||
|
||||
// Implements window.alert(message, title)
|
||||
ipcMain.on('ELECTRON_BROWSER_WINDOW_ALERT', function (event, message, title) {
|
||||
if (message == null) message = ''
|
||||
if (title == null) title = ''
|
||||
|
||||
event.returnValue = electron.dialog.showMessageBox(event.sender.getOwnerBrowserWindow(), {
|
||||
message: `${message}`,
|
||||
title: `${title}`,
|
||||
buttons: ['OK']
|
||||
})
|
||||
})
|
||||
|
||||
// Implements window.confirm(message, title)
|
||||
ipcMain.on('ELECTRON_BROWSER_WINDOW_CONFIRM', function (event, message, title) {
|
||||
if (message == null) message = ''
|
||||
if (title == null) title = ''
|
||||
|
||||
event.returnValue = !electron.dialog.showMessageBox(event.sender.getOwnerBrowserWindow(), {
|
||||
message: `${message}`,
|
||||
title: `${title}`,
|
||||
buttons: ['OK', 'Cancel'],
|
||||
cancelId: 1
|
||||
})
|
||||
})
|
||||
|
||||
// Implements window.close()
|
||||
ipcMain.on('ELECTRON_BROWSER_WINDOW_CLOSE', function (event) {
|
||||
event.sender.getOwnerBrowserWindow().close()
|
||||
event.returnValue = null
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue