import{_ as e,i as n,h as s,s as o,r as a,o as l,b as i,g as d,a as t,w as c,e as g,t as u,p as k,f as p}from"./index-ea5b20ee.js";const r={data:()=>({messageString:"",message1:"",message2:"",message3:"",mainWCid:0}),mounted(){this.init()},methods:{init(){n.removeAllListeners(s.ipcSendMsg),n.on(s.ipcSendMsg,((e,n)=>{console.log("[ipcRenderer] [socketMsgStart] result:",n),this.messageString=n,e.sender.send(s.hello,"electron-egg")})),n.removeAllListeners(o.window1ToWindow2),n.on(o.window1ToWindow2,((e,n)=>{this.$message.info(n)}))},sendMsgStart(){n.send(s.ipcSendMsg,{type:"start",content:"开始"})},sendMsgStop(){n.send(s.ipcSendMsg,{type:"end",content:""})},handleInvoke(){n.invoke(s.ipcInvokeMsg,"异步-回调").then((e=>{console.log("r:",e),this.message1=e}))},async handleInvoke2(){const e=await n.invoke(s.ipcInvokeMsg,"异步");console.log("msg:",e),this.message2=e},handleSendSync(){const e=n.sendSync(s.ipcSendSyncMsg,"同步");this.message3=e},sendTosubWindow(){n.invoke(s.getWCid,"main").then((e=>{this.mainWCid=e,n.sendTo(this.mainWCid,o.window2ToWindow1,"窗口2 通过 sendTo 给主窗口发送消息")}))}}},m=e=>(k("data-v-54ef5770"),e=e(),p(),e),v={id:"app-base-subwindow-ipc"},h=m((()=>d("div",{class:"one-block-1"},[d("span",null," 1. 发送异步消息 ")],-1))),S={class:"one-block-2"},f=m((()=>d("p",null,null,-1))),w=m((()=>d("div",{class:"one-block-1"},[d("span",null," 2. 同步消息（不推荐，阻塞执行） ")],-1))),C={class:"one-block-2"},b=m((()=>d("div",{class:"one-block-1"},[d("span",null," 3. 长消息： 服务端持续向前端页面发消息 ")],-1))),_={class:"one-block-2"},M=m((()=>d("div",{class:"one-block-1"},[d("span",null," 4. 多窗口通信：窗口之间互相通信 ")],-1))),W={class:"one-block-2"};const y=e(r,[["render",function(e,n,s,o,k,p){const r=a("a-button"),m=a("a-space");return l(),i("div",v,[h,d("div",S,[t(m,null,{default:c((()=>[t(r,{onClick:p.handleInvoke},{default:c((()=>[g("发送 - 回调")])),_:1},8,["onClick"]),g(" 结果："+u(k.message1),1)])),_:1}),f,t(m,null,{default:c((()=>[t(r,{onClick:p.handleInvoke2},{default:c((()=>[g("发送 - async/await")])),_:1},8,["onClick"]),g(" 结果："+u(k.message2),1)])),_:1})]),w,d("div",C,[t(m,null,{default:c((()=>[t(r,{onClick:p.handleSendSync},{default:c((()=>[g("同步消息")])),_:1},8,["onClick"]),g(" 结果："+u(k.message3),1)])),_:1})]),b,d("div",_,[t(m,null,{default:c((()=>[t(r,{onClick:p.sendMsgStart},{default:c((()=>[g("开始")])),_:1},8,["onClick"]),t(r,{onClick:p.sendMsgStop},{default:c((()=>[g("结束")])),_:1},8,["onClick"]),g(" 结果："+u(k.messageString),1)])),_:1})]),M,d("div",W,[t(m,null,{default:c((()=>[t(r,{onClick:n[0]||(n[0]=e=>p.sendTosubWindow())},{default:c((()=>[g("向主窗口发消息")])),_:1})])),_:1})])])}],["__scopeId","data-v-54ef5770"]]);export{y as default};
