修复打开主代码报错的问题,修复所有js加载失败均弹窗的问题

This commit is contained in:
nonameShijian 2024-02-13 14:28:06 +08:00
parent 459df4e0a4
commit 25aee55493
2 changed files with 9 additions and 7 deletions

View File

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

View File

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