From 168bca6b2c92e37bcdaafdd0f0cab1a2914cf95e Mon Sep 17 00:00:00 2001 From: kuangthree Date: Fri, 9 Feb 2024 20:45:33 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=BC=E5=85=A5=E6=89=A9=E5=B1=95=E5=87=BA?= =?UTF-8?q?=E9=94=99=E6=97=B6=E5=BC=B9=E7=AA=97=E6=8F=90=E7=A4=BA=E5=B9=B6?= =?UTF-8?q?=E8=AF=A2=E9=97=AE=E6=98=AF=E5=90=A6=E7=A7=BB=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- noname/init/import.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/noname/init/import.js b/noname/init/import.js index b3aa0c425..0fb6320d9 100644 --- a/noname/init/import.js +++ b/noname/init/import.js @@ -50,12 +50,20 @@ function generateImportFunction(type, pathParser) { return script; }; let script = createScript(); - script.onerror = () => { + script.onerror = (e) => { if (path.endsWith('.js')) { path = path.slice(0, -3) + '.ts'; script.remove(); let ts = createScript(); - ts.onerror = () => resolve(['error', ts]); + 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); + } + resolve(['error', ts]); + } document.head.appendChild(ts); } else { resolve(['error', script]);