use ipcRenderer as bridge for communication between electron and ui app

This commit is contained in:
Le Long 2017-06-13 17:02:06 +02:00
parent c47fb7cb2b
commit d52d8872be
2 changed files with 7 additions and 1 deletions

View file

@ -36,7 +36,7 @@ const baseTemplate = [
label: 'Help',
click(item, focusedWindow) {
if (focusedWindow) {
focusedWindow.loadURL(`file://${__dirname}/../dist/index.html?help`);
focusedWindow.webContents.send('open-menu', '/help');
}
}
}

View file

@ -49,6 +49,12 @@ ipcRenderer.on("open-uri-requested", (event, uri) => {
}
});
ipcRenderer.on("open-menu", (event, uri) => {
if (uri && uri.startsWith("/help")) {
app.store.dispatch(doNavigate("/help"));
}
});
document.addEventListener("click", event => {
var target = event.target;
while (target && target !== document) {