修复打开主代码报错的问题,修复所有js加载失败均弹窗的问题
This commit is contained in:
parent
459df4e0a4
commit
25aee55493
|
@ -51,17 +51,19 @@ 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) => {
|
||||
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]);
|
||||
}
|
||||
document.head.appendChild(ts);
|
||||
|
|
|
@ -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');
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue