【问题标题】:How to call some logic in Electron application from outside?如何从外部调用 Electron 应用程序中的一些逻辑?
【发布时间】:2017-05-30 14:41:05
【问题描述】:

我打算编写我的 Electron 应用程序,但我仍然不知道如何实现这样的用例 - 如何从外部调用 Electron 应用程序中的一些逻辑?

例如,有一个真正的应用程序MavensMate。我可以运行它并留在托盘中,然后从 Sublime 文本菜单中我可以在 MavensMate 中运行不同的逻辑。

【问题讨论】:

    标签: node.js electron


    【解决方案1】:

    我找到了解决办法:

    1. 在 Electron 应用中启动 ExpressJS 服务器(来自 mainProcess)

    2. 在 ExpressJS 请求处理程序中添加

      win.webContents.send('superEvent', 'ping');
      
    3. 在rendererProcess中添加

      ipcRenderer.on('superEvent', (event, arg) => {alert('pong')});
      
    4. 启动 Electon 应用程序,在浏览器中打开 ExpressJS 页面,您将在 Electron 窗口中看到警报。利润! :)

    【讨论】:

      猜你喜欢
      • 2018-03-21
      • 2011-11-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-01-17
      • 1970-01-01
      相关资源
      最近更新 更多