✨ feat: 添加 MathJax 字体文件并优化代码加载逻辑
This commit is contained in:
@@ -184,7 +184,28 @@
|
|||||||
|
|
||||||
aceAssetsPromise = new Promise(function (resolve, reject) {
|
aceAssetsPromise = new Promise(function (resolve, reject) {
|
||||||
var aceScriptSrc = aceBase + '/ace.js';
|
var aceScriptSrc = aceBase + '/ace.js';
|
||||||
|
var languageToolsSrc = aceBase + '/ext-language_tools.js';
|
||||||
var existing = documentRef.querySelector('script[data-hustoj-ace-js="' + aceScriptSrc + '"]');
|
var existing = documentRef.querySelector('script[data-hustoj-ace-js="' + aceScriptSrc + '"]');
|
||||||
|
var loadLanguageTools = function () {
|
||||||
|
var languageTools = documentRef.querySelector('script[data-hustoj-ace-js="' + languageToolsSrc + '"]');
|
||||||
|
var done = function () {
|
||||||
|
finish();
|
||||||
|
};
|
||||||
|
|
||||||
|
if (languageTools) {
|
||||||
|
languageTools.addEventListener('load', done, { once: true });
|
||||||
|
languageTools.addEventListener('error', done, { once: true });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
languageTools = documentRef.createElement('script');
|
||||||
|
languageTools.src = languageToolsSrc;
|
||||||
|
languageTools.async = true;
|
||||||
|
languageTools.setAttribute('data-hustoj-ace-js', languageToolsSrc);
|
||||||
|
languageTools.onload = done;
|
||||||
|
languageTools.onerror = done;
|
||||||
|
documentRef.head.appendChild(languageTools);
|
||||||
|
};
|
||||||
var finish = function () {
|
var finish = function () {
|
||||||
if (global.ace && global.ace.config && typeof global.ace.config.set === 'function') {
|
if (global.ace && global.ace.config && typeof global.ace.config.set === 'function') {
|
||||||
global.ace.config.set('basePath', aceBase);
|
global.ace.config.set('basePath', aceBase);
|
||||||
@@ -194,9 +215,9 @@
|
|||||||
|
|
||||||
if (existing) {
|
if (existing) {
|
||||||
if (global.ace) {
|
if (global.ace) {
|
||||||
finish();
|
loadLanguageTools();
|
||||||
} else {
|
} else {
|
||||||
existing.addEventListener('load', finish, { once: true });
|
existing.addEventListener('load', loadLanguageTools, { once: true });
|
||||||
existing.addEventListener('error', reject, { once: true });
|
existing.addEventListener('error', reject, { once: true });
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
@@ -206,7 +227,7 @@
|
|||||||
script.src = aceScriptSrc;
|
script.src = aceScriptSrc;
|
||||||
script.async = true;
|
script.async = true;
|
||||||
script.setAttribute('data-hustoj-ace-js', aceScriptSrc);
|
script.setAttribute('data-hustoj-ace-js', aceScriptSrc);
|
||||||
script.onload = finish;
|
script.onload = loadLanguageTools;
|
||||||
script.onerror = function () {
|
script.onerror = function () {
|
||||||
reject(new Error('Failed to load ' + aceScriptSrc));
|
reject(new Error('Failed to load ' + aceScriptSrc));
|
||||||
};
|
};
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
web/template/syzoj/output/chtml/fonts/woff-v2/MathJax_Zero.woff
Normal file
BIN
web/template/syzoj/output/chtml/fonts/woff-v2/MathJax_Zero.woff
Normal file
Binary file not shown.
@@ -65,7 +65,7 @@ if ($pr_flag) {
|
|||||||
|
|
||||||
.sample-box pre {
|
.sample-box pre {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
padding: 16px 18px;
|
padding: 48px 18px 16px;
|
||||||
overflow: auto;
|
overflow: auto;
|
||||||
background: transparent;
|
background: transparent;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user