Update: 移除一些无用文件同时优化代码
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
@@ -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 {
|
||||
|
||||
@@ -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();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
@@ -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');
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
@@ -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": [
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -70,6 +70,7 @@ module.exports = {
|
||||
'xscrollbar': 'XScrollbar',
|
||||
'jquery': '$',
|
||||
'ace': 'ace',
|
||||
'goog': 'goog'
|
||||
'goog': 'goog',
|
||||
'monaco': 'monaco'
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user