From 69af5bb174f2108f43cad60ca362e999fe6d4ebc 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, 20 Mar 2025 03:28:38 +0800 Subject: [PATCH] =?UTF-8?q?Update:=20=E7=A7=BB=E9=99=A4=E4=B8=80=E4=BA=9B?= =?UTF-8?q?=E6=97=A0=E7=94=A8=E6=96=87=E4=BB=B6=E5=90=8C=E6=97=B6=E4=BC=98?= =?UTF-8?q?=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/modules/mixly-modules/common/app.js | 2 +- .../mixly-modules/common/css-loader.js | 42 ++++++++------ common/modules/mixly-modules/common/nav.js | 8 +-- .../mixly-modules/common/script-loader.js | 55 +++++++++++-------- common/modules/mixly-modules/common/theme.js | 43 --------------- common/modules/mixly-modules/deps.json | 16 +----- .../mixly-modules/electron/wiki-generator.js | 6 +- webpack.common.js | 3 +- 8 files changed, 64 insertions(+), 111 deletions(-) delete mode 100644 common/modules/mixly-modules/common/theme.js diff --git a/common/modules/mixly-modules/common/app.js b/common/modules/mixly-modules/common/app.js index ebafabda..6a99560c 100644 --- a/common/modules/mixly-modules/common/app.js +++ b/common/modules/mixly-modules/common/app.js @@ -651,7 +651,7 @@ class App extends Component { if (goog.isElectron) { Loader.onbeforeunload(); } else { - let href = Config.pathPrefix + 'index.html?' + Url.jsonToUrl({ boardType: BOARD.boardType }); + let href = Env.srcDirPath + 'index.html?' + Url.jsonToUrl({ boardType: BOARD.boardType }); window.location.replace(href); } } diff --git a/common/modules/mixly-modules/common/css-loader.js b/common/modules/mixly-modules/common/css-loader.js index db274d61..62075896 100644 --- a/common/modules/mixly-modules/common/css-loader.js +++ b/common/modules/mixly-modules/common/css-loader.js @@ -1,25 +1,29 @@ +goog.loadJs('common', () => { + +goog.require('Mixly'); goog.provide('Mixly.CssLoader'); -goog.require('Mixly.Config'); -goog.require('Mixly.Env'); + + +const { CssLoader } = Mixly; /** * 加载 link 文件 * @param href */ -Mixly.CssLoader.loadCss = function (href) { - var addSign = true; - var links = document.getElementsByTagName("link"); - for (var i = 0; i < links.length; i++) { - if (links[i] && links[i].href && links[i].href.indexOf(href) != -1) { +CssLoader.loadCss = function (href) { + let addSign = true; + let links = document.getElementsByTagName('link'); + for (let i = 0; i < links.length; i++) { + if (links[i] && links[i].href && links[i].href.indexOf(href) !== -1) { addSign = false; } } if (addSign) { - var $link = document.createElement("link"); - $link.setAttribute("rel", "stylesheet"); - $link.setAttribute("type", "text/css"); - $link.setAttribute("href", href); - document.getElementsByTagName("head").item(0).appendChild($link); + let $link = document.createElement('link'); + $link.setAttribute('rel', 'stylesheet'); + $link.setAttribute('type', 'text/css'); + $link.setAttribute('href', href); + document.getElementsByTagName('head').item(0).appendChild($link); } } @@ -27,12 +31,14 @@ Mixly.CssLoader.loadCss = function (href) { * 删除 link 文件 * @param href */ -Mixly.CssLoader.removeCss = function (href) { - var links = document.getElementsByTagName("link"); - for (var i = 0; i < links.length; i++) { - var _href = links[i].href; - if (links[i] && links[i].href && links[i].href.indexOf(href) != -1) { +CssLoader.removeCss = function (href) { + let links = document.getElementsByTagName('link'); + for (let i = 0; i < links.length; i++) { + let _href = links[i].href; + if (links[i] && links[i].href && links[i].href.indexOf(href) !== -1) { links[i].parentNode.removeChild(links[i]); } } -} \ No newline at end of file +} + +}); \ No newline at end of file diff --git a/common/modules/mixly-modules/common/nav.js b/common/modules/mixly-modules/common/nav.js index e55b3825..a447891e 100644 --- a/common/modules/mixly-modules/common/nav.js +++ b/common/modules/mixly-modules/common/nav.js @@ -3,8 +3,6 @@ goog.loadJs('common', () => { goog.require('layui'); goog.require('$.select2'); goog.require('Mixly.Env'); -goog.require('Mixly.Config'); -goog.require('Mixly.Command'); goog.require('Mixly.XML'); goog.require('Mixly.Msg'); goog.require('Mixly.HTMLTemplate'); @@ -13,17 +11,13 @@ goog.provide('Mixly.Nav'); const { Env, - Config, - Command, XML, Msg, HTMLTemplate, Component } = Mixly; -const { BOARD, USER } = Config; - -const { element, form } = layui; +const { element } = layui; class Nav extends Component { diff --git a/common/modules/mixly-modules/common/script-loader.js b/common/modules/mixly-modules/common/script-loader.js index 6a75a26d..363f841a 100644 --- a/common/modules/mixly-modules/common/script-loader.js +++ b/common/modules/mixly-modules/common/script-loader.js @@ -1,24 +1,29 @@ -goog.require('Mixly'); +goog.loadJs('common', () => { + +goog.require('Mixly.Env'); goog.provide('Mixly.ScriptLoader'); + +const { Env, ScriptLoader } = Mixly; + /** * 加载 script 文件 * @param src */ -Mixly.ScriptLoader.loadScript = function (src) { - var addSign = true; - var scripts = document.getElementsByTagName("script"); - for (var i = 0; i < scripts.length; i++) { - if (scripts[i] && scripts[i].src && scripts[i].src.indexOf(src) != -1) { +ScriptLoader.loadScript = function (src) { + let addSign = true; + let scripts = document.getElementsByTagName('script'); + for (let i = 0; i < scripts.length; i++) { + if (scripts[i] && scripts[i].src && scripts[i].src.indexOf(src) !== -1) { addSign = false; } } if (addSign) { - var $script = document.createElement('script'); - $script.setAttribute("type", "text/javascript"); - $script.setAttribute("src", src); - //$script.setAttribute("async", ""); - document.getElementsByTagName("head").item(0).appendChild($script); + let $script = document.createElement('script'); + $script.setAttribute('type', 'text/javascript'); + $script.setAttribute('src', src); + //$script.setAttribute('async', ''); + document.getElementsByTagName('head').item(0).appendChild($script); } } @@ -26,33 +31,35 @@ Mixly.ScriptLoader.loadScript = function (src) { * 删除 script 文件 * @param src */ -Mixly.ScriptLoader.removeScript = function (src) { - var scripts = document.getElementsByTagName("script"); - if (src.indexOf("../") !== -1) { - src = src.substring(src.lastIndexOf("../") + 3, src.length); +ScriptLoader.removeScript = function (src) { + let scripts = document.getElementsByTagName('script'); + if (src.indexOf('../') !== -1) { + src = src.substring(src.lastIndexOf('../') + 3, src.length); } - for (var i = 0; i < scripts.length; i++) { - if (scripts[i] && scripts[i].src && scripts[i].src.indexOf(src) != -1) { + for (let i = 0; i < scripts.length; i++) { + if (scripts[i] && scripts[i].src && scripts[i].src.indexOf(src) !== -1) { scripts[i].parentNode.removeChild(scripts[i]); } } } -Mixly.ScriptLoader.loadLangJs = function (oldLang, newLang, doFunc) { - var scripts = document.querySelectorAll("script"); +ScriptLoader.loadLangJs = function (oldLang, newLang, doFunc) { + let scripts = document.querySelectorAll('script'); let newLangPathArr = []; for (let i = 0; i < scripts.length; i++) { - if (scripts[i] && scripts[i].src && scripts[i].src.indexOf(oldLang + ".js") != -1) { + if (scripts[i] && scripts[i].src && scripts[i].src.indexOf(oldLang + '.js') !== -1) { let oldLangPath = scripts[i].src; - let newLangPath = oldLangPath.replace(oldLang + ".js", newLang + ".js"); + let newLangPath = oldLangPath.replace(oldLang + '.js', newLang + '.js'); scripts[i].parentNode.removeChild(scripts[i]); newLangPathArr.push(newLangPath); } } - for (let i = 0; i < Mixly.Env.thirdPartyJS.length; i++) { - Mixly.Env.thirdPartyJS[i] = Mixly.Env.thirdPartyJS[i].replace(oldLang + ".js", newLang + ".js"); + for (let i = 0; i < Env.thirdPartyJS.length; i++) { + Env.thirdPartyJS[i] = Env.thirdPartyJS[i].replace(oldLang + '.js', newLang + '.js'); } LazyLoad.js(newLangPathArr, function () { doFunc(); }); -} \ No newline at end of file +} + +}); \ No newline at end of file diff --git a/common/modules/mixly-modules/common/theme.js b/common/modules/mixly-modules/common/theme.js deleted file mode 100644 index 1766b64d..00000000 --- a/common/modules/mixly-modules/common/theme.js +++ /dev/null @@ -1,43 +0,0 @@ -goog.loadJs('common', () => { - -goog.require('Blockly'); -goog.provide('Mixly.Theme'); - -const { Theme } = Mixly; - -Theme.changeTo = function (type) { - const { blockEditor, codeEditor } = Editor; - let blockEditorTheme, codeEditorTheme, statusBarTheme; - if (type === 'dark') { - $("#nav").removeClass("layui-bg-green").addClass("layui-bg-cyan"); - $("body").removeClass("light").addClass("dark"); - blockEditorTheme = Blockly.Themes.Dark; - codeEditorTheme = 'ace/theme/dracula'; - statusBarTheme = 'ace/theme/terminal'; - } else { - $("#nav").removeClass("layui-bg-cyan").addClass("layui-bg-green"); - $("body").removeClass("dark").addClass("light"); - blockEditorTheme = Blockly.Themes.Classic; - codeEditorTheme = "ace/theme/crimson_editor"; - if (Blockly.Arduino) { - codeEditorTheme = "ace/theme/xcode"; - } - statusBarTheme = 'ace/theme/xcode'; - } - blockEditor.setTheme(blockEditorTheme); - codeEditor.setOption("theme", codeEditorTheme); - // for (let statusBar of StatusBarTabs.statusBars) { - // statusBar.editor.setOption("theme", statusBarTheme); - // } -} - -const themeMedia = window.matchMedia("(prefers-color-scheme: light)"); -themeMedia.addListener(e => { - if (e.matches) { - Theme.changeTo('light'); - } else { - Theme.changeTo('dark'); - } -}); - -}); \ No newline at end of file diff --git a/common/modules/mixly-modules/deps.json b/common/modules/mixly-modules/deps.json index 724d2247..d2f04a36 100644 --- a/common/modules/mixly-modules/deps.json +++ b/common/modules/mixly-modules/deps.json @@ -159,8 +159,7 @@ { "path": "/common/css-loader.js", "require": [ - "Mixly.Config", - "Mixly.Env" + "Mixly" ], "provide": [ "Mixly.CssLoader" @@ -747,8 +746,6 @@ "layui", "$.select2", "Mixly.Env", - "Mixly.Config", - "Mixly.Command", "Mixly.XML", "Mixly.Msg", "Mixly.HTMLTemplate", @@ -829,7 +826,7 @@ { "path": "/common/script-loader.js", "require": [ - "Mixly" + "Mixly.Env" ], "provide": [ "Mixly.ScriptLoader" @@ -1114,15 +1111,6 @@ "Mixly.Storage" ] }, - { - "path": "/common/theme.js", - "require": [ - "Blockly" - ], - "provide": [ - "Mixly.Theme" - ] - }, { "path": "/common/title.js", "require": [ diff --git a/common/modules/mixly-modules/electron/wiki-generator.js b/common/modules/mixly-modules/electron/wiki-generator.js index 6e93e4cc..a25db11c 100644 --- a/common/modules/mixly-modules/electron/wiki-generator.js +++ b/common/modules/mixly-modules/electron/wiki-generator.js @@ -25,11 +25,11 @@ class WikiGenerator { #$xml_ = null; #desPath_ = ''; #tree_ = []; - constructor($xml, desPath) { + constructor(workspace, generator, $xml, desPath) { this.#$xml_ = $xml; this.#desPath_ = desPath; - this.workspace = Mixly.Workspace.getMain().getEditorsManager().getActive().getPage('block').getEditor(); - this.generator = Mixly.Workspace.getMain().getEditorsManager().getActive().getPage('block').generator; + this.workspace = workspace; + this.generator = generator; } buildTree($nodes) { diff --git a/webpack.common.js b/webpack.common.js index 63118dea..df0a3546 100644 --- a/webpack.common.js +++ b/webpack.common.js @@ -70,6 +70,7 @@ module.exports = { 'xscrollbar': 'XScrollbar', 'jquery': '$', 'ace': 'ace', - 'goog': 'goog' + 'goog': 'goog', + 'monaco': 'monaco' } };