Update: 移除一些无用文件同时优化代码
This commit is contained in:
@@ -651,7 +651,7 @@ class App extends Component {
|
|||||||
if (goog.isElectron) {
|
if (goog.isElectron) {
|
||||||
Loader.onbeforeunload();
|
Loader.onbeforeunload();
|
||||||
} else {
|
} 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);
|
window.location.replace(href);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,25 +1,29 @@
|
|||||||
|
goog.loadJs('common', () => {
|
||||||
|
|
||||||
|
goog.require('Mixly');
|
||||||
goog.provide('Mixly.CssLoader');
|
goog.provide('Mixly.CssLoader');
|
||||||
goog.require('Mixly.Config');
|
|
||||||
goog.require('Mixly.Env');
|
|
||||||
|
const { CssLoader } = Mixly;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 加载 link 文件
|
* 加载 link 文件
|
||||||
* @param href
|
* @param href
|
||||||
*/
|
*/
|
||||||
Mixly.CssLoader.loadCss = function (href) {
|
CssLoader.loadCss = function (href) {
|
||||||
var addSign = true;
|
let addSign = true;
|
||||||
var links = document.getElementsByTagName("link");
|
let links = document.getElementsByTagName('link');
|
||||||
for (var i = 0; i < links.length; i++) {
|
for (let i = 0; i < links.length; i++) {
|
||||||
if (links[i] && links[i].href && links[i].href.indexOf(href) != -1) {
|
if (links[i] && links[i].href && links[i].href.indexOf(href) !== -1) {
|
||||||
addSign = false;
|
addSign = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (addSign) {
|
if (addSign) {
|
||||||
var $link = document.createElement("link");
|
let $link = document.createElement('link');
|
||||||
$link.setAttribute("rel", "stylesheet");
|
$link.setAttribute('rel', 'stylesheet');
|
||||||
$link.setAttribute("type", "text/css");
|
$link.setAttribute('type', 'text/css');
|
||||||
$link.setAttribute("href", href);
|
$link.setAttribute('href', href);
|
||||||
document.getElementsByTagName("head").item(0).appendChild($link);
|
document.getElementsByTagName('head').item(0).appendChild($link);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -27,12 +31,14 @@ Mixly.CssLoader.loadCss = function (href) {
|
|||||||
* 删除 link 文件
|
* 删除 link 文件
|
||||||
* @param href
|
* @param href
|
||||||
*/
|
*/
|
||||||
Mixly.CssLoader.removeCss = function (href) {
|
CssLoader.removeCss = function (href) {
|
||||||
var links = document.getElementsByTagName("link");
|
let links = document.getElementsByTagName('link');
|
||||||
for (var i = 0; i < links.length; i++) {
|
for (let i = 0; i < links.length; i++) {
|
||||||
var _href = links[i].href;
|
let _href = links[i].href;
|
||||||
if (links[i] && links[i].href && links[i].href.indexOf(href) != -1) {
|
if (links[i] && links[i].href && links[i].href.indexOf(href) !== -1) {
|
||||||
links[i].parentNode.removeChild(links[i]);
|
links[i].parentNode.removeChild(links[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
});
|
||||||
@@ -3,8 +3,6 @@ goog.loadJs('common', () => {
|
|||||||
goog.require('layui');
|
goog.require('layui');
|
||||||
goog.require('$.select2');
|
goog.require('$.select2');
|
||||||
goog.require('Mixly.Env');
|
goog.require('Mixly.Env');
|
||||||
goog.require('Mixly.Config');
|
|
||||||
goog.require('Mixly.Command');
|
|
||||||
goog.require('Mixly.XML');
|
goog.require('Mixly.XML');
|
||||||
goog.require('Mixly.Msg');
|
goog.require('Mixly.Msg');
|
||||||
goog.require('Mixly.HTMLTemplate');
|
goog.require('Mixly.HTMLTemplate');
|
||||||
@@ -13,17 +11,13 @@ goog.provide('Mixly.Nav');
|
|||||||
|
|
||||||
const {
|
const {
|
||||||
Env,
|
Env,
|
||||||
Config,
|
|
||||||
Command,
|
|
||||||
XML,
|
XML,
|
||||||
Msg,
|
Msg,
|
||||||
HTMLTemplate,
|
HTMLTemplate,
|
||||||
Component
|
Component
|
||||||
} = Mixly;
|
} = Mixly;
|
||||||
|
|
||||||
const { BOARD, USER } = Config;
|
const { element } = layui;
|
||||||
|
|
||||||
const { element, form } = layui;
|
|
||||||
|
|
||||||
|
|
||||||
class Nav extends Component {
|
class Nav extends Component {
|
||||||
|
|||||||
@@ -1,24 +1,29 @@
|
|||||||
goog.require('Mixly');
|
goog.loadJs('common', () => {
|
||||||
|
|
||||||
|
goog.require('Mixly.Env');
|
||||||
goog.provide('Mixly.ScriptLoader');
|
goog.provide('Mixly.ScriptLoader');
|
||||||
|
|
||||||
|
|
||||||
|
const { Env, ScriptLoader } = Mixly;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 加载 script 文件
|
* 加载 script 文件
|
||||||
* @param src
|
* @param src
|
||||||
*/
|
*/
|
||||||
Mixly.ScriptLoader.loadScript = function (src) {
|
ScriptLoader.loadScript = function (src) {
|
||||||
var addSign = true;
|
let addSign = true;
|
||||||
var scripts = document.getElementsByTagName("script");
|
let scripts = document.getElementsByTagName('script');
|
||||||
for (var i = 0; i < scripts.length; i++) {
|
for (let i = 0; i < scripts.length; i++) {
|
||||||
if (scripts[i] && scripts[i].src && scripts[i].src.indexOf(src) != -1) {
|
if (scripts[i] && scripts[i].src && scripts[i].src.indexOf(src) !== -1) {
|
||||||
addSign = false;
|
addSign = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (addSign) {
|
if (addSign) {
|
||||||
var $script = document.createElement('script');
|
let $script = document.createElement('script');
|
||||||
$script.setAttribute("type", "text/javascript");
|
$script.setAttribute('type', 'text/javascript');
|
||||||
$script.setAttribute("src", src);
|
$script.setAttribute('src', src);
|
||||||
//$script.setAttribute("async", "");
|
//$script.setAttribute('async', '');
|
||||||
document.getElementsByTagName("head").item(0).appendChild($script);
|
document.getElementsByTagName('head').item(0).appendChild($script);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -26,33 +31,35 @@ Mixly.ScriptLoader.loadScript = function (src) {
|
|||||||
* 删除 script 文件
|
* 删除 script 文件
|
||||||
* @param src
|
* @param src
|
||||||
*/
|
*/
|
||||||
Mixly.ScriptLoader.removeScript = function (src) {
|
ScriptLoader.removeScript = function (src) {
|
||||||
var scripts = document.getElementsByTagName("script");
|
let scripts = document.getElementsByTagName('script');
|
||||||
if (src.indexOf("../") !== -1) {
|
if (src.indexOf('../') !== -1) {
|
||||||
src = src.substring(src.lastIndexOf("../") + 3, src.length);
|
src = src.substring(src.lastIndexOf('../') + 3, src.length);
|
||||||
}
|
}
|
||||||
for (var i = 0; i < scripts.length; i++) {
|
for (let i = 0; i < scripts.length; i++) {
|
||||||
if (scripts[i] && scripts[i].src && scripts[i].src.indexOf(src) != -1) {
|
if (scripts[i] && scripts[i].src && scripts[i].src.indexOf(src) !== -1) {
|
||||||
scripts[i].parentNode.removeChild(scripts[i]);
|
scripts[i].parentNode.removeChild(scripts[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Mixly.ScriptLoader.loadLangJs = function (oldLang, newLang, doFunc) {
|
ScriptLoader.loadLangJs = function (oldLang, newLang, doFunc) {
|
||||||
var scripts = document.querySelectorAll("script");
|
let scripts = document.querySelectorAll('script');
|
||||||
let newLangPathArr = [];
|
let newLangPathArr = [];
|
||||||
for (let i = 0; i < scripts.length; i++) {
|
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 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]);
|
scripts[i].parentNode.removeChild(scripts[i]);
|
||||||
newLangPathArr.push(newLangPath);
|
newLangPathArr.push(newLangPath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (let i = 0; i < Mixly.Env.thirdPartyJS.length; i++) {
|
for (let i = 0; i < Env.thirdPartyJS.length; i++) {
|
||||||
Mixly.Env.thirdPartyJS[i] = Mixly.Env.thirdPartyJS[i].replace(oldLang + ".js", newLang + ".js");
|
Env.thirdPartyJS[i] = Env.thirdPartyJS[i].replace(oldLang + '.js', newLang + '.js');
|
||||||
}
|
}
|
||||||
LazyLoad.js(newLangPathArr, function () {
|
LazyLoad.js(newLangPathArr, function () {
|
||||||
doFunc();
|
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",
|
"path": "/common/css-loader.js",
|
||||||
"require": [
|
"require": [
|
||||||
"Mixly.Config",
|
"Mixly"
|
||||||
"Mixly.Env"
|
|
||||||
],
|
],
|
||||||
"provide": [
|
"provide": [
|
||||||
"Mixly.CssLoader"
|
"Mixly.CssLoader"
|
||||||
@@ -747,8 +746,6 @@
|
|||||||
"layui",
|
"layui",
|
||||||
"$.select2",
|
"$.select2",
|
||||||
"Mixly.Env",
|
"Mixly.Env",
|
||||||
"Mixly.Config",
|
|
||||||
"Mixly.Command",
|
|
||||||
"Mixly.XML",
|
"Mixly.XML",
|
||||||
"Mixly.Msg",
|
"Mixly.Msg",
|
||||||
"Mixly.HTMLTemplate",
|
"Mixly.HTMLTemplate",
|
||||||
@@ -829,7 +826,7 @@
|
|||||||
{
|
{
|
||||||
"path": "/common/script-loader.js",
|
"path": "/common/script-loader.js",
|
||||||
"require": [
|
"require": [
|
||||||
"Mixly"
|
"Mixly.Env"
|
||||||
],
|
],
|
||||||
"provide": [
|
"provide": [
|
||||||
"Mixly.ScriptLoader"
|
"Mixly.ScriptLoader"
|
||||||
@@ -1114,15 +1111,6 @@
|
|||||||
"Mixly.Storage"
|
"Mixly.Storage"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"path": "/common/theme.js",
|
|
||||||
"require": [
|
|
||||||
"Blockly"
|
|
||||||
],
|
|
||||||
"provide": [
|
|
||||||
"Mixly.Theme"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"path": "/common/title.js",
|
"path": "/common/title.js",
|
||||||
"require": [
|
"require": [
|
||||||
|
|||||||
@@ -25,11 +25,11 @@ class WikiGenerator {
|
|||||||
#$xml_ = null;
|
#$xml_ = null;
|
||||||
#desPath_ = '';
|
#desPath_ = '';
|
||||||
#tree_ = [];
|
#tree_ = [];
|
||||||
constructor($xml, desPath) {
|
constructor(workspace, generator, $xml, desPath) {
|
||||||
this.#$xml_ = $xml;
|
this.#$xml_ = $xml;
|
||||||
this.#desPath_ = desPath;
|
this.#desPath_ = desPath;
|
||||||
this.workspace = Mixly.Workspace.getMain().getEditorsManager().getActive().getPage('block').getEditor();
|
this.workspace = workspace;
|
||||||
this.generator = Mixly.Workspace.getMain().getEditorsManager().getActive().getPage('block').generator;
|
this.generator = generator;
|
||||||
}
|
}
|
||||||
|
|
||||||
buildTree($nodes) {
|
buildTree($nodes) {
|
||||||
|
|||||||
@@ -70,6 +70,7 @@ module.exports = {
|
|||||||
'xscrollbar': 'XScrollbar',
|
'xscrollbar': 'XScrollbar',
|
||||||
'jquery': '$',
|
'jquery': '$',
|
||||||
'ace': 'ace',
|
'ace': 'ace',
|
||||||
'goog': 'goog'
|
'goog': 'goog',
|
||||||
|
'monaco': 'monaco'
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user