From 82b2524fda8a681c0de4a9a15954d51f689f0b45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E7=AB=8B=E5=B8=AE?= <3294713004@qq.com> Date: Fri, 4 Oct 2024 21:34:49 +0800 Subject: [PATCH] =?UTF-8?q?Update:=20=E8=B0=83=E6=95=B4=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E8=B7=AF=E5=BE=84=EF=BC=8C=E7=A7=BB=E9=99=A4=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E8=B7=AF=E5=BE=84=E5=89=8D=E7=BC=80=20`file://`=20=E5=92=8C=20?= =?UTF-8?q?`https://`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/modules/mixly-modules/common/env.js | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/common/modules/mixly-modules/common/env.js b/common/modules/mixly-modules/common/env.js index 1e953c82..0d024c27 100644 --- a/common/modules/mixly-modules/common/env.js +++ b/common/modules/mixly-modules/common/env.js @@ -45,15 +45,19 @@ Env.python3Path = null; */ Env.pyFilePath = null; +let htmlPath = decodeURIComponent((new URL($('html')[0].baseURI)).pathname); +let baseJsPath = decodeURIComponent((new URL(goog.basePath)).pathname); + +if (goog.isElectron && Env.currentPlatform === 'win32') { + htmlPath = htmlPath.substring(1); + baseJsPath = baseJsPath.substring(1); +} + /** * 获取板卡index或主页面index的路径 * @type {String} */ -Env.indexDirPath = path.join((new URL($('html')[0].baseURI)).href, '../').replace(/file:\/+/g, ''); -Env.indexDirPath = decodeURIComponent(Env.indexDirPath); -if (goog.isElectron && ['darwin', 'linux'].includes(Env.currentPlatform)) { - Env.indexDirPath = '/' + Env.indexDirPath; -} +Env.indexDirPath = path.join(htmlPath, '../'); /** * 资源文件夹所在路径 @@ -89,20 +93,20 @@ Env.thirdPartyJS = []; * 默认模板路径 * @type {String} */ -Env.templatePath = path.join(goog.basePath, '../templates/'); +Env.templatePath = path.join(baseJsPath, '../templates/'); /** * 语言文件路径 * @type {String} */ -Env.msgPath = path.join(goog.basePath, '../msg/'); +Env.msgPath = path.join(baseJsPath, '../msg/'); /** * 模板index所在路径 * @type {String} */ const urlConfig = Url.getConfig() ?? {}; -Env.boardIndexPath = path.join(Env.indexDirPath, '../', urlConfig.boardIndex ?? ''); +Env.boardIndexPath = path.join(Env.indexDirPath, '../', urlConfig.boardIndex ?? 'index.xml'); /** * 模板index所在目录路径