use ipc dialog instead of javascript alert when running in electron
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
const { app, BrowserWindow, ipcMain, systemPreferences } = require('electron');
|
||||
const { app, BrowserWindow, dialog, ipcMain, systemPreferences } = require('electron');
|
||||
const electronPrompt = require('electron-prompt');
|
||||
const { spawn } = require('child_process');
|
||||
const fs = require('fs');
|
||||
@@ -15,6 +15,13 @@ ipcMain.handle('app-version', async() => {
|
||||
return app.getVersion();
|
||||
});
|
||||
|
||||
// add support for showing an alert window via ipc
|
||||
ipcMain.handle('alert', async(event, message) => {
|
||||
return await dialog.showMessageBox(mainWindow, {
|
||||
message: message,
|
||||
});
|
||||
});
|
||||
|
||||
// add support for showing a prompt window via ipc
|
||||
ipcMain.handle('prompt', async(event, message) => {
|
||||
return await electronPrompt({
|
||||
|
||||
@@ -10,6 +10,11 @@ contextBridge.exposeInMainWorld('electron', {
|
||||
return await ipcRenderer.invoke('app-version');
|
||||
},
|
||||
|
||||
// show an alert dialog in electron browser window, this fixes a bug where alert breaks input fields on windows
|
||||
alert: async function(message) {
|
||||
return await ipcRenderer.invoke('alert', message);
|
||||
},
|
||||
|
||||
// add support for using "prompt" in electron browser window
|
||||
prompt: async function(message) {
|
||||
return await ipcRenderer.invoke('prompt', message);
|
||||
|
||||
Reference in New Issue
Block a user