fix: 修复插件导入的bug

pull/409/head
xiaojunnuo 2025-05-16 08:55:54 +08:00
parent 61f06faaf5
commit 677fec0a0b
2 changed files with 10 additions and 9 deletions

View File

@ -91,6 +91,7 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat
},
afterSubmit() {
notification.success({ message: "操作成功" });
crudExpose.doRefresh();
},
async doSubmit({ form }: any) {
return await api.ImportPlugin({

View File

@ -438,25 +438,25 @@ export class PluginService extends BaseService<PluginEntity> {
...loaded,
metadata: yaml.dump(metadata),
extra: yaml.dump(extra),
content: req.content,
content: loaded.content,
disabled: false
};
if (!pluginEntity.pluginType) {
throw new Error(`插件类型不能为空`);
}
if (old) {
if (!req.override) {
throw new Error(`插件${loaded.author}/${loaded.name}已存在`);
}
//update
pluginEntity.id = old.id;
await this.update(pluginEntity);
} else {
if (!old) {
//add
const {id} = await this.add(pluginEntity);
pluginEntity.id = id;
} else{
if (!req.override) {
throw new Error(`插件${loaded.author}/${loaded.name}已存在`);
}
pluginEntity.id = old.id;
}
//update
await this.update(pluginEntity);
return {
id: pluginEntity.id
};