以下代码均来自于我开发的开源软件:
窗口A的渲染进程发消息给主进程const { clipboard, ipcRenderer, remote} = require('electron'); ipcRenderer.send('imgUploadMain', { id: dom.id, siteId: this.siteId, url: dom.src });
主进程收到消息后,再发消息给窗口B的渲染进程
import { app, BrowserWindow, ipcMain, Menu} from 'electron'ipcMain.on('imgUploadMain', (event, message) => { mainWindow.webContents.send('imgUploadMsgFromMain', message);});
窗口B渲染进程接收主进程消息的代码:
const { ipcRenderer, remote} = require('electron');ipcRenderer.on('imgUploadMsgFromMain', (e, message) => this.imgUploadCb(message));