file协议模式demo

This commit is contained in:
gaoshuaixing
2023-06-27 16:35:48 +08:00
parent 432083de20
commit b1715343ed
29 changed files with 32 additions and 27 deletions

View File

@@ -38,7 +38,7 @@ module.exports = (appInfo) => {
/**
* 应用程序顶部菜单
*/
config.openAppMenu = 'dev-show';
config.openAppMenu = true;
/**
* 主窗口
@@ -132,7 +132,7 @@ module.exports = (appInfo) => {
* 主进程
*/
config.mainServer = {
protocol: 'http://',
protocol: 'file://',
indexPath: '/public/dist/index.html',
host: 'localhost',
port: 7072,

View File

@@ -130,7 +130,11 @@ class OsController extends Controller {
let addr = 'http://localhost:8080'
if (Ps.isProd()) {
const mainServer = Conf.getValue('mainServer');
addr = mainServer.protocol + mainServer.host + ':' + mainServer.port;
if (Conf.isFileProtocol(mainServer)) {
addr = path.join(Ps.getHomeDir(), mainServer.indexPath);
} else {
addr = mainServer.protocol + mainServer.host + ':' + mainServer.port;
}
}
contentUrl = addr + content;

View File

@@ -54,7 +54,7 @@
</div>
</template>
<script>
import { ipcApiRoute, specialIpcRoute } from '@/api/main'
import { ipcApiRoute, specialIpcRoute } from '@/api/main';
export default {
data() {
return {
@@ -67,7 +67,7 @@ export default {
views: [
{
type: 'vue',
content: '/#/special/subwindow',
content: '#/special/subwindow',
windowName: 'window-ipc',
windowTitle: 'ipc window'
},

View File

@@ -33,7 +33,7 @@
</div>
</template>
<script>
import { ipcApiRoute } from '@/api/main'
import { ipcApiRoute } from '@/api/main';
export default {
data() {
@@ -53,7 +53,7 @@ export default {
},
{
type: 'vue',
content: '/#/special/subwindow',
content: '#/special/subwindow',
windowName: 'window-vue',
windowTitle: 'vue window'
},

View File

@@ -2,6 +2,7 @@ module.exports = {
//Solution For Issue:You are using the runtime-only build of Vue where the template compiler is not available. Either pre-compile the templates into render functions, or use the compiler-included build.
//zhengkai.blog.csdn.net
runtimeCompiler: true,
publicPath: './',
configureWebpack: (config) => {
config["performance"] = {
"maxEntrypointSize": 10000000,

View File

@@ -1 +0,0 @@
#app-base-window[data-v-be4003c2]{padding:0 10px;text-align:left;width:100%}#app-base-window .one-block-1[data-v-be4003c2]{font-size:16px;padding-top:10px}#app-base-window .one-block-2[data-v-be4003c2]{padding-top:10px}

View File

@@ -0,0 +1 @@
#app-base-window[data-v-8818b996]{padding:0 10px;text-align:left;width:100%}#app-base-window .one-block-1[data-v-8818b996]{font-size:16px;padding-top:10px}#app-base-window .one-block-2[data-v-8818b996]{padding-top:10px}

View File

@@ -0,0 +1 @@
#app-base-jobs[data-v-09b653a0]{padding:0 10px;text-align:left;width:100%}#app-base-jobs .one-block-1[data-v-09b653a0]{font-size:16px;padding-top:10px}#app-base-jobs .one-block-2[data-v-09b653a0]{padding-top:10px}

View File

@@ -1 +0,0 @@
#app-base-jobs[data-v-0a164fce]{padding:0 10px;text-align:left;width:100%}#app-base-jobs .one-block-1[data-v-0a164fce]{font-size:16px;padding-top:10px}#app-base-jobs .one-block-2[data-v-0a164fce]{padding-top:10px}

View File

@@ -0,0 +1 @@
#app-base-socket-ipc[data-v-a8bb976a]{padding:0 10px;text-align:left;width:100%}#app-base-socket-ipc .one-block-1[data-v-a8bb976a]{font-size:16px;padding-top:10px}#app-base-socket-ipc .one-block-2[data-v-a8bb976a]{padding-top:10px}

View File

@@ -1 +0,0 @@
#app-base-socket-ipc[data-v-010d9bff]{padding:0 10px;text-align:left;width:100%}#app-base-socket-ipc .one-block-1[data-v-010d9bff]{font-size:16px;padding-top:10px}#app-base-socket-ipc .one-block-2[data-v-010d9bff]{padding-top:10px}

View File

@@ -4,4 +4,4 @@
::-webkit-scrollbar-track{background:0 0}
::-webkit-scrollbar-thumb{background:#E6FFEE;-webkit-transition:.3s;transition:.3s}
::-webkit-scrollbar-thumb:hover{background-color:#07C160}
::-webkit-scrollbar-thumb:active{background-color:#07C160}</style><link href="/css/chunk-09b6db32.420fdb6d.css" rel="prefetch"><link href="/css/chunk-0b695420.01116c37.css" rel="prefetch"><link href="/css/chunk-0c3ec28a.57f7ab37.css" rel="prefetch"><link href="/css/chunk-1ac5e88a.4a15bba1.css" rel="prefetch"><link href="/css/chunk-1caa1be6.198b3d4f.css" rel="prefetch"><link href="/css/chunk-21689cc4.6784fb2b.css" rel="prefetch"><link href="/css/chunk-2bb45275.7b3b5479.css" rel="prefetch"><link href="/css/chunk-2c1b05fb.c240d69c.css" rel="prefetch"><link href="/css/chunk-2ed2f5b2.4abd2c84.css" rel="prefetch"><link href="/css/chunk-31638db2.dd7e28b0.css" rel="prefetch"><link href="/css/chunk-41d5921a.3febd410.css" rel="prefetch"><link href="/css/chunk-45af09d4.38508275.css" rel="prefetch"><link href="/css/chunk-5c6e7977.3a28c15a.css" rel="prefetch"><link href="/css/chunk-68bb1024.a8b5de09.css" rel="prefetch"><link href="/css/chunk-68d57b43.2dda727d.css" rel="prefetch"><link href="/css/chunk-69fb44ca.f714bef4.css" rel="prefetch"><link href="/css/chunk-72ffb39f.af4f6a12.css" rel="prefetch"><link href="/css/chunk-c19bf770.80cd7ae2.css" rel="prefetch"><link href="/css/chunk-e16c8452.c241bcac.css" rel="prefetch"><link href="/css/chunk-ec5e0b1e.8389c666.css" rel="prefetch"><link href="/css/chunk-f98fc72c.90fc6ee5.css" rel="prefetch"><link href="/js/chunk-09b6db32.78adb757.js" rel="prefetch"><link href="/js/chunk-0b695420.a3fd2f88.js" rel="prefetch"><link href="/js/chunk-0c3ec28a.9aad6973.js" rel="prefetch"><link href="/js/chunk-1ac5e88a.8235ec8e.js" rel="prefetch"><link href="/js/chunk-1caa1be6.7d0684f9.js" rel="prefetch"><link href="/js/chunk-21689cc4.a999222a.js" rel="prefetch"><link href="/js/chunk-2bb45275.f4608420.js" rel="prefetch"><link href="/js/chunk-2c1b05fb.a967f24b.js" rel="prefetch"><link href="/js/chunk-2ed2f5b2.5a19baa0.js" rel="prefetch"><link href="/js/chunk-31638db2.0e39434a.js" rel="prefetch"><link href="/js/chunk-41d5921a.f0a16fa7.js" rel="prefetch"><link href="/js/chunk-45af09d4.86f080bb.js" rel="prefetch"><link href="/js/chunk-5c6e7977.fe68e3ca.js" rel="prefetch"><link href="/js/chunk-68bb1024.fb033b2a.js" rel="prefetch"><link href="/js/chunk-68d57b43.4691343a.js" rel="prefetch"><link href="/js/chunk-69fb44ca.4e8421b3.js" rel="prefetch"><link href="/js/chunk-72ffb39f.07568d94.js" rel="prefetch"><link href="/js/chunk-c19bf770.844b9dd3.js" rel="prefetch"><link href="/js/chunk-e16c8452.17d51e99.js" rel="prefetch"><link href="/js/chunk-ec5e0b1e.14969463.js" rel="prefetch"><link href="/js/chunk-ef5c6832.7db6bab4.js" rel="prefetch"><link href="/js/chunk-f98fc72c.6df89cdd.js" rel="prefetch"><link href="/css/app.8ada1737.css" rel="preload" as="style"><link href="/css/chunk-vendors.f4913a35.css" rel="preload" as="style"><link href="/js/app.73f33250.js" rel="preload" as="script"><link href="/js/chunk-vendors.f687bef1.js" rel="preload" as="script"><link href="/css/chunk-vendors.f4913a35.css" rel="stylesheet"><link href="/css/app.8ada1737.css" rel="stylesheet"></head><body><noscript><strong>We're sorry but it doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id="app"></div><script src="/js/chunk-vendors.f687bef1.js"></script><script src="/js/app.73f33250.js"></script></body></html>
::-webkit-scrollbar-thumb:active{background-color:#07C160}</style><link href="css/chunk-09b6db32.420fdb6d.css" rel="prefetch"><link href="css/chunk-0b695420.01116c37.css" rel="prefetch"><link href="css/chunk-0c3ec28a.57f7ab37.css" rel="prefetch"><link href="css/chunk-1ac5e88a.4a15bba1.css" rel="prefetch"><link href="css/chunk-1caa1be6.198b3d4f.css" rel="prefetch"><link href="css/chunk-2bb45275.7b3b5479.css" rel="prefetch"><link href="css/chunk-2c1b05fb.c240d69c.css" rel="prefetch"><link href="css/chunk-2ed2f5b2.4abd2c84.css" rel="prefetch"><link href="css/chunk-31638db2.dd7e28b0.css" rel="prefetch"><link href="css/chunk-41d5921a.3febd410.css" rel="prefetch"><link href="css/chunk-4508ae8b.32cffba8.css" rel="prefetch"><link href="css/chunk-45af09d4.38508275.css" rel="prefetch"><link href="css/chunk-5c6e7977.3a28c15a.css" rel="prefetch"><link href="css/chunk-5c9637cf.0e8925eb.css" rel="prefetch"><link href="css/chunk-68d57b43.2dda727d.css" rel="prefetch"><link href="css/chunk-69fb44ca.f714bef4.css" rel="prefetch"><link href="css/chunk-6b482e42.e21cb584.css" rel="prefetch"><link href="css/chunk-72ffb39f.af4f6a12.css" rel="prefetch"><link href="css/chunk-c19bf770.80cd7ae2.css" rel="prefetch"><link href="css/chunk-e16c8452.c241bcac.css" rel="prefetch"><link href="css/chunk-ec5e0b1e.8389c666.css" rel="prefetch"><link href="js/chunk-09b6db32.78adb757.js" rel="prefetch"><link href="js/chunk-0b695420.a3fd2f88.js" rel="prefetch"><link href="js/chunk-0c3ec28a.9aad6973.js" rel="prefetch"><link href="js/chunk-1ac5e88a.8235ec8e.js" rel="prefetch"><link href="js/chunk-1caa1be6.7d0684f9.js" rel="prefetch"><link href="js/chunk-2bb45275.f4608420.js" rel="prefetch"><link href="js/chunk-2c1b05fb.a967f24b.js" rel="prefetch"><link href="js/chunk-2ed2f5b2.5a19baa0.js" rel="prefetch"><link href="js/chunk-31638db2.0e39434a.js" rel="prefetch"><link href="js/chunk-41d5921a.f0a16fa7.js" rel="prefetch"><link href="js/chunk-4508ae8b.909c575f.js" rel="prefetch"><link href="js/chunk-45af09d4.86f080bb.js" rel="prefetch"><link href="js/chunk-5c6e7977.fe68e3ca.js" rel="prefetch"><link href="js/chunk-5c9637cf.044e9bf5.js" rel="prefetch"><link href="js/chunk-68d57b43.4691343a.js" rel="prefetch"><link href="js/chunk-69fb44ca.4e8421b3.js" rel="prefetch"><link href="js/chunk-6b482e42.1ca10db8.js" rel="prefetch"><link href="js/chunk-72ffb39f.07568d94.js" rel="prefetch"><link href="js/chunk-c19bf770.844b9dd3.js" rel="prefetch"><link href="js/chunk-e16c8452.17d51e99.js" rel="prefetch"><link href="js/chunk-ec5e0b1e.14969463.js" rel="prefetch"><link href="js/chunk-ef5c6832.7db6bab4.js" rel="prefetch"><link href="css/app.8ada1737.css" rel="preload" as="style"><link href="css/chunk-vendors.f4913a35.css" rel="preload" as="style"><link href="js/app.62fa9244.js" rel="preload" as="script"><link href="js/chunk-vendors.20126134.js" rel="preload" as="script"><link href="css/chunk-vendors.f4913a35.css" rel="stylesheet"><link href="css/app.8ada1737.css" rel="stylesheet"></head><body><noscript><strong>We're sorry but it doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id="app"></div><script src="js/chunk-vendors.20126134.js"></script><script src="js/app.62fa9244.js"></script></body></html>

2
public/dist/js/app.62fa9244.js vendored Normal file

File diff suppressed because one or more lines are too long

1
public/dist/js/app.62fa9244.js.map vendored Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

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

File diff suppressed because one or more lines are too long

View File

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

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long