【问题标题】:How to perform function call of the main process in the main process of the electron?如何在电子的主进程中进行主进程的函数调用?
【发布时间】:2019-03-09 18:54:32
【问题描述】:

我正在使用电子创建一个应用程序,我正在创建一个托盘菜单,通过单击它我想执行一个已经实现的操作,我已经从进程渲染器调用了该操作,但我尝试了并没有通过调用主进程的 from 来成功重用这个函数。

TRAY 在主进程中:

const traytemplate = [{
   'label': 'About',
   click: () => {
        / * make call here * /
   }
}
]

开窗功能

ipcMain.on ('open-over', () => {
      / * open the window over here * /
})

我需要从主进程中调用“open-over”。有人可以帮我吗?

我想知道如何从它(主进程)执行主进程函数的调用,因为我已经使用从渲染器进程调用这个函数

*** 在建议之前,我的托盘无法在渲染器中创建并在那里工作。

提前致谢

【问题讨论】:

    标签: electron


    【解决方案1】:

    如何命名处理函数?

    const openWindow = () => {
      // open the window
    }
    
    ipcMain.on('open-hover', openWindow)
    
    const traytemplate = [{
      'label': 'About',
      click: () => {
        openWindow()
      }
    }]
    

    【讨论】:

      猜你喜欢
      • 2018-01-21
      • 2018-04-03
      • 2021-05-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-06-04
      相关资源
      最近更新 更多