他们是否有任何工具来简化IPC和在单个网页和node.js进程之间进行数据封送?
我读过:http://tangiblejs.com/posts/nw-js-and-electron-compared-2016-edition
概述了nw.js与电子的区别。两者看起来差不多,但我喜欢在不需要的时候最小化复杂性,所以我倾向于使用nw.js来避免IPC的问题。
但是这可能是一个错误,因为我看到更多关于电子的评论在这个组中,而不是NW.JS。
(我的IDE将是Visual代码,它现在有一个扩展用于NW.JS调试,但没有一个扩展用于电子)。
发布于 2017-01-15 14:21:53
为此,我们开始使用NWJS,也因为它支持chrome.serial
。最近,出于几个原因,我将该项目转换为电子产品:
您是对的,NWJS没有主/呈现过程的复杂性,但我发现很少有理由必须处理IPC。
许多API只能在主过程中使用,但可以通过远程 API进行访问。因此,例如,要从呈现进程获得对主的访问,我使用:
{process} = require('electron').remote
process.argv ...
在我的index.js中,我不得不做一些IPC操作,但是电子有库来简化这个过程:
// ensure we only have a single instance, but pass args to renderer to open any files passed by explorer
const shouldQuit = app.makeSingleInstance((argv, workingDir) => {
win.webContents.send('open-instance', argv);
})
然后,在我的呈现程序代码中,我有以下内容:
ipcRenderer.on('open-instance', (event, arg) => {
this.restoreAndFocus();
// TODO - handle another instance opening a file from explorer
});
https://stackoverflow.com/questions/41594687
复制相似问题