From 25aee55493b8ea910d98a4b60557292ac9a114dc Mon Sep 17 00:00:00 2001 From: nonameShijian <2954700422@qq.com> Date: Tue, 13 Feb 2024 14:28:06 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=89=93=E5=BC=80=E4=B8=BB?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E6=8A=A5=E9=94=99=E7=9A=84=E9=97=AE=E9=A2=98?= =?UTF-8?q?=EF=BC=8C=E4=BF=AE=E5=A4=8D=E6=89=80=E6=9C=89js=E5=8A=A0?= =?UTF-8?q?=E8=BD=BD=E5=A4=B1=E8=B4=A5=E5=9D=87=E5=BC=B9=E7=AA=97=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- noname/init/import.js | 14 ++++++++------ noname/ui/index.js | 2 +- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/noname/init/import.js b/noname/init/import.js index 0fb6320d9..75ee63341 100644 --- a/noname/init/import.js +++ b/noname/init/import.js @@ -51,16 +51,18 @@ function generateImportFunction(type, pathParser) { }; let script = createScript(); script.onerror = (e) => { - if (path.endsWith('.js')) { + if (path.endsWith('.js') && window.isSecureContext) { path = path.slice(0, -3) + '.ts'; script.remove(); let ts = createScript(); ts.onerror = (e2) => { - console.error(`扩展《${name}》加载失败`,e,e2); - let remove = confirm(`扩展《${name}》加载失败,是否移除此扩展?此操作不会移除目录下的文件。`); - if(remove){ - lib.config.extensions.remove(name); - game.saveConfig('extensions',lib.config.extensions); + if (lib.path.basename(path) === 'extension.js' && lib.path.dirname(path).endsWith('/extension')) { + console.error(`扩展《${name}》加载失败`, e, e2); + let remove = confirm(`扩展《${name}》加载失败,是否移除此扩展?此操作不会移除目录下的文件。`); + if (remove) { + lib.config.extensions.remove(name); + game.saveConfig('extensions', lib.config.extensions); + } } resolve(['error', ts]); } diff --git a/noname/ui/index.js b/noname/ui/index.js index a3638acfa..c0ddc7ae2 100644 --- a/noname/ui/index.js +++ b/noname/ui/index.js @@ -5906,7 +5906,7 @@ class Create extends Uninstantable { else { if (!window.CodeMirror) { import('../../game/codemirror.js').then(() => { - lib.codeMirrorReady(node, editor); + lib.codeMirrorReady(node, this.editor); }); lib.init.css(lib.assetURL + 'layout/default', 'codemirror'); }