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