From a70dcaf7fb00e965d3d323b70b1bcb8ef2e0a62c Mon Sep 17 00:00:00 2001 From: langxm Date: Wed, 14 Oct 2026 03:29:12 +0800 Subject: [PATCH] =?UTF-8?q?fix(P4):=20Monaco=20loader=20=E6=94=B9=E5=8A=A8?= =?UTF-8?q?=E6=80=81=E6=B3=A8=E5=85=A5=E2=80=94=E2=80=94=E9=81=BF=E5=85=8D?= =?UTF-8?q?=E4=B8=8E=20CodeMirror=20mode(clike/python)=20AMD=20=E5=8C=BF?= =?UTF-8?q?=E5=90=8D=20define=20=E5=86=B2=E7=AA=81(one=20anonymous=20defin?= =?UTF-8?q?e=20call)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/index.html | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/frontend/index.html b/frontend/index.html index ee6f1cc..be93ce1 100644 --- a/frontend/index.html +++ b/frontend/index.html @@ -246,7 +246,6 @@ body{font-family:var(--sans);background:var(--bg);color:var(--text);font-size:14
加载中…
- @@ -319,9 +318,11 @@ function init(){ loadLatexChips(); // LaTeX 常用公式合集(按学科) latexLive(); // 预览区默认示例 } -/* ================= 编辑器:Monaco(CDN)优先,CodeMirror 回退 ================= */ +/* ================= 编辑器:Monaco(动态注入,避免与 CodeMirror mode 的 AMD 分支冲突)优先,CodeMirror 回退 ================= */ function initEditor(){ - if(window.require && document.getElementById('cmWrap')){ + var s=document.createElement('script'); + s.src='/vendor/monaco/min/vs/loader.js'; + s.onload=function(){ try{ window.require.config({paths:{vs:'/vendor/monaco/min/vs'}}); var t=setTimeout(function(){ if(!MONACO_BOOTED) bootCodeMirror(); },6000); @@ -330,7 +331,9 @@ function initEditor(){ try{ bootMonaco(); }catch(e){ bootCodeMirror(); } }, function(){ clearTimeout(t); bootCodeMirror(); }); }catch(e){ bootCodeMirror(); } - } else bootCodeMirror(); + }; + s.onerror=function(){ bootCodeMirror(); }; + document.head.appendChild(s); } function bootCodeMirror(){ CM = CodeMirror(document.getElementById('cmWrap'), {