成功进行ipc通信

This commit is contained in:
linyuchen
2023-10-27 17:31:19 +08:00
parent ab17e3cd30
commit 881570c513
6 changed files with 789 additions and 58 deletions

View File

@@ -1,5 +1,17 @@
// Electron 主进程 与 渲染进程 交互的桥梁
const { contextBridge } = require("electron");
const { ipcRenderer } = require('electron');
// 在window对象下导出只读对象
contextBridge.exposeInMainWorld("plugin_template", {
contextBridge.exposeInMainWorld("llonebot", {
listenSendMessage: (handle: (msg: any)=>void)=>{
ipcRenderer.on("sendMsg", (event: any, args: any) => {
handle("收到ipc消息发送消息")
console.log("收到ipc消息发送消息", args); // 处理主进程发送的消息
})
},
startExpress:()=>{
ipcRenderer.send("startExpress");
}
// startExpress,
});