From 3b10f7742ca0fa2593c9443d3125c921f8c906bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E7=AB=8B=E5=B8=AE?= <3294713004@qq.com> Date: Thu, 8 May 2025 23:06:26 +0800 Subject: [PATCH] =?UTF-8?q?feat(core):=20=E5=9C=A8=E7=BA=BF=E7=89=88=20`co?= =?UTF-8?q?mpiler`=20=E6=A8=A1=E5=BC=8F=E4=B8=8B=E5=85=81=E8=AE=B8?= =?UTF-8?q?=E8=87=AA=E5=AE=9A=E4=B9=89url?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/modules/mixly-modules/deps.json | 2 ++ common/modules/mixly-modules/web-compiler/loader.js | 12 +++++++++++- common/modules/mixly-modules/web-socket/loader.js | 12 +++++++++++- sw-config.json | 2 ++ 4 files changed, 26 insertions(+), 2 deletions(-) diff --git a/common/modules/mixly-modules/deps.json b/common/modules/mixly-modules/deps.json index 9b187ec7..85576c12 100644 --- a/common/modules/mixly-modules/deps.json +++ b/common/modules/mixly-modules/deps.json @@ -1750,6 +1750,7 @@ "path": "/web-compiler/loader.js", "require": [ "Mixly.Debug", + "Mixly.Config", "Mixly.StatusBarsManager", "Mixly.Socket", "Mixly.WebCompiler.ArduShell" @@ -1845,6 +1846,7 @@ "path": "/web-socket/loader.js", "require": [ "Mixly.Debug", + "Mixly.Config", "Mixly.StatusBarsManager", "Mixly.Socket", "Mixly.WebSocket.Serial", diff --git a/common/modules/mixly-modules/web-compiler/loader.js b/common/modules/mixly-modules/web-compiler/loader.js index 2abc7c78..ce4fba16 100644 --- a/common/modules/mixly-modules/web-compiler/loader.js +++ b/common/modules/mixly-modules/web-compiler/loader.js @@ -1,6 +1,7 @@ goog.loadJs('web', () => { goog.require('Mixly.Debug'); +goog.require('Mixly.Config'); goog.require('Mixly.StatusBarsManager'); goog.require('Mixly.Socket'); goog.require('Mixly.WebCompiler.ArduShell'); @@ -8,6 +9,7 @@ goog.provide('Mixly.WebCompiler.Loader'); const { Debug, + Config, StatusBarsManager, Socket, WebCompiler @@ -18,9 +20,17 @@ const { ArduShell } = WebCompiler; +const { SOFTWARE } = Config; + Loader.init = function () { - const mixlySocket = new Socket(`wss://${location.hostname}:4000/compile`, { + let url = ''; + if (SOFTWARE.webCompiler?.url) { + url = SOFTWARE.webCompiler.url; + } else { + url = `wss://${window.location.host}`; + } + const mixlySocket = new Socket(`${url}/compile`, { path: '/mixly-socket/', reconnection: true, reconnectionDelayMax: 10000, diff --git a/common/modules/mixly-modules/web-socket/loader.js b/common/modules/mixly-modules/web-socket/loader.js index fbccbe32..ab439bf5 100644 --- a/common/modules/mixly-modules/web-socket/loader.js +++ b/common/modules/mixly-modules/web-socket/loader.js @@ -1,6 +1,7 @@ goog.loadJs('web', () => { goog.require('Mixly.Debug'); +goog.require('Mixly.Config'); goog.require('Mixly.StatusBarsManager'); goog.require('Mixly.Socket'); goog.require('Mixly.WebSocket.Serial'); @@ -11,6 +12,7 @@ goog.provide('Mixly.WebSocket.Loader'); const { Debug, + Config, StatusBarsManager, Socket, WebSocket @@ -24,9 +26,17 @@ const { Ampy } = WebSocket; +const { SOFTWARE } = Config; + Loader.init = function () { - const mixlySocket = new Socket(`wss://${location.hostname}:4000/all`, { + let url = ''; + if (SOFTWARE.webSocket?.url) { + url = SOFTWARE.webSocket.url; + } else { + url = `wss://${window.location.host}`; + } + const mixlySocket = new Socket(`${url}/all`, { path: '/mixly-socket/', reconnection: true, reconnectionDelayMax: 10000, diff --git a/sw-config.json b/sw-config.json index ab55b041..8f5e1451 100644 --- a/sw-config.json +++ b/sw-config.json @@ -18,9 +18,11 @@ } }, "webSocket": { + "url": "", "enabled": false }, "webCompiler": { + "url": "", "enabled": false }, "behaviorRecord": {