From 9eb5e500fe669cf2bbf8fe6e380d254b090538c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E7=AB=8B=E5=B8=AE?= <3294713004@qq.com> Date: Mon, 24 Feb 2025 23:10:39 +0800 Subject: [PATCH] =?UTF-8?q?Fix:=20=E4=BF=AE=E5=A4=8Dnwjs=E6=89=93=E5=8C=85?= =?UTF-8?q?=E5=90=8E=E6=9D=BF=E5=8D=A1=E9=A1=B5=E9=9D=A2=E8=BD=BD=E5=85=A5?= =?UTF-8?q?=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/main.js | 2 ++ common/modules/mixly-modules/common/config.js | 2 +- common/modules/mixly-modules/common/editor-blockly.js | 2 +- common/modules/mixly-modules/common/serial.js | 4 ++-- common/modules/mixly-modules/electron/loader.js | 2 +- 5 files changed, 7 insertions(+), 5 deletions(-) diff --git a/common/main.js b/common/main.js index a747c87f..bf71da03 100644 --- a/common/main.js +++ b/common/main.js @@ -123,6 +123,8 @@ LazyLoad.js([ const path = require('path'); if (inPath.indexOf(window.location.origin) !== -1) { inPath = inPath.replace(window.location.origin, nw.__dirname); + } else if (!inPath.indexOf('/')) { + inPath = path.resolve(nw.__dirname, './' + inPath); } else { let dirPath; if (fs.existsSync(nw.__filename) && fs.statSync(nw.__filename).isFile()) { diff --git a/common/modules/mixly-modules/common/config.js b/common/modules/mixly-modules/common/config.js index b229dc00..77d2b810 100644 --- a/common/modules/mixly-modules/common/config.js +++ b/common/modules/mixly-modules/common/config.js @@ -62,7 +62,7 @@ Config.init = () => { let pathPrefix = '../'; - Config.SOFTWARE = goog.getJSON(path.join(pathPrefix, 'sw-config.json'), SOFTWARE_DEFAULT_CONFIG); + Config.SOFTWARE = goog.getJSON(path.join(Env.srcDirPath, 'sw-config.json'), SOFTWARE_DEFAULT_CONFIG); Config.pathPrefix = pathPrefix; Env.hasSocketServer = Config.SOFTWARE?.webSocket?.enabled ? true : false; diff --git a/common/modules/mixly-modules/common/editor-blockly.js b/common/modules/mixly-modules/common/editor-blockly.js index 02b12c7d..ad5bc6a0 100644 --- a/common/modules/mixly-modules/common/editor-blockly.js +++ b/common/modules/mixly-modules/common/editor-blockly.js @@ -59,7 +59,7 @@ class EditorBlockly extends EditorBase { this.workspace = null; this.initBlockly = () => { const DEFAULT_CATEGORIES = HTMLTemplate.get('xml/default-categories.xml').render(); - const media = path.join(Config.pathPrefix, 'common/media/'); + const media = path.join(Env.srcDirPath, 'common/media/'); const renderer = ['geras', 'zelos'].includes(USER.blockRenderer) ? USER.blockRenderer : 'geras'; this.editor = Blockly.inject(this.$blockly[0], { media, diff --git a/common/modules/mixly-modules/common/serial.js b/common/modules/mixly-modules/common/serial.js index cb56b7b8..7b43d4c5 100644 --- a/common/modules/mixly-modules/common/serial.js +++ b/common/modules/mixly-modules/common/serial.js @@ -13,7 +13,7 @@ const { Msg } = Mixly; -const { BOARD } = Config; +const { SELECTED_BOARD } = Config; class Serial { @@ -43,7 +43,7 @@ class Serial { } this.getConfig = function () { - let config = BOARD?.serial ?? {}; + let config = SELECTED_BOARD?.serial ?? {}; return { ...this.DEFAULT_CONFIG, ...config diff --git a/common/modules/mixly-modules/electron/loader.js b/common/modules/mixly-modules/electron/loader.js index 944a0c3e..afb1e557 100644 --- a/common/modules/mixly-modules/electron/loader.js +++ b/common/modules/mixly-modules/electron/loader.js @@ -32,7 +32,7 @@ Loader.onbeforeunload = function(reload = false) { window.location.reload(true); } } - let href = Config.pathPrefix + 'index.html?' + Url.jsonToUrl({ boardType: BOARD.boardType ?? 'None' }); + let href = Env.srcDirPath + '/index.html?' + Url.jsonToUrl({ boardType: BOARD.boardType ?? 'None' }); let endPromise = []; const { mainStatusBarTabs } = Mixly; Serial.getCurrentPortsName().map((name) => {