调整不加载扩展逻辑

This commit is contained in:
kuangthree 2024-01-22 22:28:40 +08:00
parent 52600363c4
commit 9895d8ed2a
2 changed files with 3 additions and 3 deletions

View File

@ -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:"",

View File

@ -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);
});