企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
[TOC] ## ipcMain 与 ipcRenderer 进程间的通讯 [https://electronjs.org/docs/api/ipc-renderer](https://electronjs.org/docs/api/ipc-renderer) ``` ipcRenderer.on(channel, listener) ipcRenderer.once(channel, listener) 只地监听一次后删除 ipcRenderer.removeAllListeners(channel) ipcRenderer.send(channel[, arg1][, arg2][, ...]) ``` main.js ``` //ipcMain 处理 ipcMain.on("main_liston",(event,arg)=>{ console.log(arg); event.sender.send("renderer_liston",'main to renderer') }) ``` other.js ``` const {ipcRenderer} = require('electron'); ipcRenderer.send('main_liston',`renderer to main num:`); ipcRenderer.on('renderer_liston',(event,arg)=>{ //arg }) ```