1.0.2 • Published 2 months ago

electronjs-prompt v1.0.2

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
2 months ago

_prompt

A Sync prompt that kinda copies the original prompt behavior for electronjs (untested outside of my laptop)

How to use

Simply require it in main.js

const {Prompt} = require("electronjs-prompt");

Then call the constructor (there's no personalisations yet for the windows and design)

async function loadMainWindow() {
    win = new BrowserWindow({
        width: 800, height: 600, show: false, webPreferences: {
            preload: path.join(__dirname, 'preload.js'), nodeIntegration: true, contextIsolation: false
        }, autoHideMenuBar: true
    })

    win.loadURL(`file://${app.getAppPath()}/public/index.html?app_path=${app.getAppPath()}`).then(r => {
        win.show();
    });

    win.webContents.on('did-finish-load', () => {
        win.maximize();
    });

    new Prompt(ipcMain);
}

You can then call prompt from your renderer using

return ipcRenderer.sendSync('prompt', msg);

It now also works with confirm and sends back an integer (0 | 1)

return ipcRenderer.sendSync('confirm', msg);
1.0.2

2 months ago

1.0.1

2 months ago

1.0.0

2 months ago