导入扩展出错时弹窗提示并询问是否移除
This commit is contained in:
parent
0f4feae5a4
commit
168bca6b2c
|
@ -50,12 +50,20 @@ function generateImportFunction(type, pathParser) {
|
||||||
return script;
|
return script;
|
||||||
};
|
};
|
||||||
let script = createScript();
|
let script = createScript();
|
||||||
script.onerror = () => {
|
script.onerror = (e) => {
|
||||||
if (path.endsWith('.js')) {
|
if (path.endsWith('.js')) {
|
||||||
path = path.slice(0, -3) + '.ts';
|
path = path.slice(0, -3) + '.ts';
|
||||||
script.remove();
|
script.remove();
|
||||||
let ts = createScript();
|
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);
|
document.head.appendChild(ts);
|
||||||
} else {
|
} else {
|
||||||
resolve(['error', script]);
|
resolve(['error', script]);
|
||||||
|
|
Loading…
Reference in New Issue