Fix: 修复nwjs打包后板卡页面载入异常
This commit is contained in:
@@ -123,6 +123,8 @@ LazyLoad.js([
|
|||||||
const path = require('path');
|
const path = require('path');
|
||||||
if (inPath.indexOf(window.location.origin) !== -1) {
|
if (inPath.indexOf(window.location.origin) !== -1) {
|
||||||
inPath = inPath.replace(window.location.origin, nw.__dirname);
|
inPath = inPath.replace(window.location.origin, nw.__dirname);
|
||||||
|
} else if (!inPath.indexOf('/')) {
|
||||||
|
inPath = path.resolve(nw.__dirname, './' + inPath);
|
||||||
} else {
|
} else {
|
||||||
let dirPath;
|
let dirPath;
|
||||||
if (fs.existsSync(nw.__filename) && fs.statSync(nw.__filename).isFile()) {
|
if (fs.existsSync(nw.__filename) && fs.statSync(nw.__filename).isFile()) {
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ Config.init = () => {
|
|||||||
|
|
||||||
let pathPrefix = '../';
|
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;
|
Config.pathPrefix = pathPrefix;
|
||||||
|
|
||||||
Env.hasSocketServer = Config.SOFTWARE?.webSocket?.enabled ? true : false;
|
Env.hasSocketServer = Config.SOFTWARE?.webSocket?.enabled ? true : false;
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ class EditorBlockly extends EditorBase {
|
|||||||
this.workspace = null;
|
this.workspace = null;
|
||||||
this.initBlockly = () => {
|
this.initBlockly = () => {
|
||||||
const DEFAULT_CATEGORIES = HTMLTemplate.get('xml/default-categories.xml').render();
|
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';
|
const renderer = ['geras', 'zelos'].includes(USER.blockRenderer) ? USER.blockRenderer : 'geras';
|
||||||
this.editor = Blockly.inject(this.$blockly[0], {
|
this.editor = Blockly.inject(this.$blockly[0], {
|
||||||
media,
|
media,
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ const {
|
|||||||
Msg
|
Msg
|
||||||
} = Mixly;
|
} = Mixly;
|
||||||
|
|
||||||
const { BOARD } = Config;
|
const { SELECTED_BOARD } = Config;
|
||||||
|
|
||||||
|
|
||||||
class Serial {
|
class Serial {
|
||||||
@@ -43,7 +43,7 @@ class Serial {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.getConfig = function () {
|
this.getConfig = function () {
|
||||||
let config = BOARD?.serial ?? {};
|
let config = SELECTED_BOARD?.serial ?? {};
|
||||||
return {
|
return {
|
||||||
...this.DEFAULT_CONFIG,
|
...this.DEFAULT_CONFIG,
|
||||||
...config
|
...config
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ Loader.onbeforeunload = function(reload = false) {
|
|||||||
window.location.reload(true);
|
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 = [];
|
let endPromise = [];
|
||||||
const { mainStatusBarTabs } = Mixly;
|
const { mainStatusBarTabs } = Mixly;
|
||||||
Serial.getCurrentPortsName().map((name) => {
|
Serial.getCurrentPortsName().map((name) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user