From 52600363c4e53b0c2ab69257a49d3603d59e6c30 Mon Sep 17 00:00:00 2001 From: kuangthree Date: Mon, 22 Jan 2024 21:12:19 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=9C=AA=E5=BC=80=E5=90=AF=E6=89=A9?= =?UTF-8?q?=E5=B1=95=E4=B8=8D=E6=89=A7=E8=A1=8C=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- noname/init/import.js | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/noname/init/import.js b/noname/init/import.js index e09689ea4..b755cd541 100644 --- a/noname/init/import.js +++ b/noname/init/import.js @@ -35,6 +35,10 @@ export const importMode = generateImportFunction('mode', (name) => `../../mode/$ function generateImportFunction(type, pathParser) { return async (name) => { const path = pathParser(name); + if(type == 'extension' && !game.hasExtension(name)){ + await game.import(type,createEmptyExtension(name)); + return; + } // 通过浏览器自带的script标签导入可直接获取报错信息,且不会影响JS运行 // 此时代码内容也将缓存在浏览器中,故再次import后将不会重新执行代码内容(测试下来如此) const [status, script] = await new Promise((resolve) => { @@ -53,3 +57,32 @@ function generateImportFunction(type, pathParser) { await game.import(type, modeContent.default); } } + +function createEmptyExtension(name){ + return {name:name,content:function(config,pack){},precontent:function(){},config:{},help:{},package:{ + character:{ + character:{ + }, + translate:{ + }, + }, + card:{ + card:{ + }, + translate:{ + }, + list:[], + }, + skill:{ + skill:{ + }, + translate:{ + }, + }, + intro:"扩展《"+name+"》尚未开启,请开启后查看信息。", + author:"未知", + diskURL:"", + forumURL:"", + version:"1.0", + },files:{"character":[],"card":[],"skill":[],"audio":[]}} +} \ No newline at end of file From 9895d8ed2a3bb50b09f8869836a8696d873560a8 Mon Sep 17 00:00:00 2001 From: kuangthree Date: Mon, 22 Jan 2024 22:28:40 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E8=B0=83=E6=95=B4=E4=B8=8D=E5=8A=A0?= =?UTF-8?q?=E8=BD=BD=E6=89=A9=E5=B1=95=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- noname/init/import.js | 4 ++-- noname/init/index.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/noname/init/import.js b/noname/init/import.js index b755cd541..5f1bd9671 100644 --- a/noname/init/import.js +++ b/noname/init/import.js @@ -34,11 +34,11 @@ export const importMode = generateImportFunction('mode', (name) => `../../mode/$ */ function generateImportFunction(type, pathParser) { return async (name) => { - const path = pathParser(name); if(type == 'extension' && !game.hasExtension(name)){ await game.import(type,createEmptyExtension(name)); return; } + const path = pathParser(name); // 通过浏览器自带的script标签导入可直接获取报错信息,且不会影响JS运行 // 此时代码内容也将缓存在浏览器中,故再次import后将不会重新执行代码内容(测试下来如此) const [status, script] = await new Promise((resolve) => { @@ -79,7 +79,7 @@ function createEmptyExtension(name){ translate:{ }, }, - intro:"扩展《"+name+"》尚未开启,请开启后查看信息。", + intro:`扩展《${name}》尚未开启,请开启后查看信息。`, author:"未知", diskURL:"", forumURL:"", diff --git a/noname/init/index.js b/noname/init/index.js index 0a37ea546..489fdf6be 100644 --- a/noname/init/index.js +++ b/noname/init/index.js @@ -499,7 +499,7 @@ export async function boot() { } // await Promise.allSettled(_status.extensionLoading); - _status.extensionLoaded.filter(Boolean).forEach((name) => { + _status.extensionLoaded.filter(name=>game.hasExtension(name)).forEach((name) => { lib.announce.publish("Noname.Init.Extension.onLoad", name); lib.announce.publish(`Noname.Init.Extension.${name}.onLoad`, void 0); });