mirror of
https://github.com/liamcottle/reticulum-meshchat.git
synced 2026-04-27 16:10:32 +00:00
use ipc dialog instead of javascript alert when running in electron
This commit is contained in:
parent
f9d802b393
commit
205a4d0a1d
3 changed files with 39 additions and 18 deletions
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue