| 12 |
- (window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-ec5e0b1e"],{"4b7c":function(n,e,s){},"7a64":function(n,e,s){"use strict";s.r(e);var t=function(){var n=this,e=n.$createElement,s=n._self._c||e;return s("div",{attrs:{id:"app-base-subwindow-ipc"}},[n._m(0),s("div",{staticClass:"one-block-2"},[s("a-space",[s("a-button",{on:{click:n.handleInvoke}},[n._v("发送 - 回调")]),n._v(" 结果:"+n._s(n.message1)+" ")],1),s("p"),s("a-space",[s("a-button",{on:{click:n.handleInvoke2}},[n._v("发送 - async/await")]),n._v(" 结果:"+n._s(n.message2)+" ")],1)],1),n._m(1),s("div",{staticClass:"one-block-2"},[s("a-space",[s("a-button",{on:{click:n.handleSendSync}},[n._v("同步消息")]),n._v(" 结果:"+n._s(n.message3)+" ")],1)],1),n._m(2),s("div",{staticClass:"one-block-2"},[s("a-space",[s("a-button",{on:{click:n.sendMsgStart}},[n._v("开始")]),s("a-button",{on:{click:n.sendMsgStop}},[n._v("结束")]),n._v(" 结果:"+n._s(n.messageString)+" ")],1)],1),n._m(3),s("div",{staticClass:"one-block-2"},[s("a-space",[s("a-button",{on:{click:function(e){return n.sendTosubWindow()}}},[n._v("向主窗口发消息")])],1)],1)])},i=[function(){var n=this,e=n.$createElement,s=n._self._c||e;return s("div",{staticClass:"one-block-1"},[s("span",[n._v(" 1. 发送异步消息 ")])])},function(){var n=this,e=n.$createElement,s=n._self._c||e;return s("div",{staticClass:"one-block-1"},[s("span",[n._v(" 2. 同步消息(不推荐,阻塞执行) ")])])},function(){var n=this,e=n.$createElement,s=n._self._c||e;return s("div",{staticClass:"one-block-1"},[s("span",[n._v(" 3. 长消息: 服务端持续向前端页面发消息 ")])])},function(){var n=this,e=n.$createElement,s=n._self._c||e;return s("div",{staticClass:"one-block-1"},[s("span",[n._v(" 4. 多窗口通信:窗口之间互相通信 ")])])}],c=s("1da1"),a=(s("96cf"),s("a358")),o={data:function(){return{messageString:"",message1:"",message2:"",message3:"",mainWCid:0}},mounted:function(){this.init()},methods:{init:function(){var n=this,e=this;this.$ipc.removeAllListeners(a["a"].ipcSendMsg),this.$ipc.on(a["a"].ipcSendMsg,(function(n,s){console.log("[ipcRenderer] [socketMsgStart] result:",s),e.messageString=s,n.sender.send(a["a"].hello,"electron-egg")})),this.$ipc.removeAllListeners(a["c"].window1ToWindow2),this.$ipc.on(a["c"].window1ToWindow2,(function(e,s){n.$message.info(s)}))},sendMsgStart:function(){var n={type:"start",content:"开始"};this.$ipc.send(a["a"].ipcSendMsg,n)},sendMsgStop:function(){var n={type:"end",content:""};this.$ipc.send(a["a"].ipcSendMsg,n)},handleInvoke:function(){var n=this;this.$ipc.invoke(a["a"].ipcInvokeMsg,"异步-回调").then((function(e){console.log("r:",e),n.message1=e}))},handleInvoke2:function(){var n=this;return Object(c["a"])(regeneratorRuntime.mark((function e(){var s;return regeneratorRuntime.wrap((function(e){while(1)switch(e.prev=e.next){case 0:return e.next=2,n.$ipc.invoke(a["a"].ipcInvokeMsg,"异步");case 2:s=e.sent,console.log("msg:",s),n.message2=s;case 5:case"end":return e.stop()}}),e)})))()},handleSendSync:function(){var n=this.$ipc.sendSync(a["a"].ipcSendSyncMsg,"同步");this.message3=n},sendTosubWindow:function(){var n=this;this.$ipc.invoke(a["a"].getWCid,"main").then((function(e){n.mainWCid=e,n.$ipc.sendTo(n.mainWCid,a["c"].window2ToWindow1,"窗口2 通过 sendTo 给主窗口发送消息")}))}}},r=o,d=(s("803e"),s("2877")),l=Object(d["a"])(r,t,i,!1,null,"59c87dd9",null);e["default"]=l.exports},"803e":function(n,e,s){"use strict";s("4b7c")}}]);
- //# sourceMappingURL=chunk-ec5e0b1e.0b27b030.js.map
|