fix: 修复导入在线插件不生效的bug

This commit is contained in:
xiaojunnuo
2025-05-16 08:38:38 +08:00
parent 76b19a4980
commit fcf8309c23
5 changed files with 98 additions and 38 deletions
@@ -193,10 +193,49 @@ export class PluginService extends BaseService<PluginEntity> {
throw new Error(`插件类型${param.pluginType}不支持`);
}
return await super.add({
const res= await super.add({
...param,
...plugin
});
await this.registerById(res.id);
return res
}
async registerById(id: any) {
const item = await this.info(id);
if (!item) {
return;
}
if(item.type === "builtIn"){
return;
}
await this.registerPlugin(item);
}
async unRegisterById(id: any){
const item = await this.info(id);
if (!item) {
return;
}
if (item.type === "builtIn") {
return;
}
let name = item.name;
if (item.author){
name = `${item.author}/${item.name}`
}
if (item.pluginType === "access"){
accessRegistry.unRegister(name)
}else if (item.pluginType === "deploy"){
pluginRegistry.unRegister(name)
}else if (item.pluginType === "dnsProvider"){
dnsProviderRegistry.unRegister(name)
}else if (item.pluginType === "notification"){
notificationRegistry.unRegister(name)
}else{
logger.warn(`不支持的插件类型:${item.pluginType}`)
}
}
async update(param: any) {
@@ -211,7 +250,11 @@ export class PluginService extends BaseService<PluginEntity> {
throw new Error(`插件${param.author}/${param.name}已存在`);
}
return await super.update(param);
const res= await super.update(param);
await this.registerById(param.id);
return res
}
async compile(code: string) {
@@ -420,4 +463,12 @@ export class PluginService extends BaseService<PluginEntity> {
}
async deleteByIds(ids:any[]){
await super.delete(ids);
for (const id of ids) {
await this.unRegisterById(id)
}
}
}