mirror of
https://github.com/certd/certd.git
synced 2026-04-24 20:57:26 +08:00
fix: 修复自定义插件删除后没有反注册的bug
This commit is contained in:
@@ -76,10 +76,12 @@ export abstract class BaseService<T> {
|
|||||||
* @param where
|
* @param where
|
||||||
*/
|
*/
|
||||||
async delete(ids: string | any[], where?: any) {
|
async delete(ids: string | any[], where?: any) {
|
||||||
const idArr = this.resolveIdArr(ids);
|
let idArr = this.resolveIdArr(ids);
|
||||||
|
idArr = this.filterIds(idArr);
|
||||||
if (idArr.length === 0) {
|
if (idArr.length === 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
await this.getRepository().delete({
|
await this.getRepository().delete({
|
||||||
id: In(idArr),
|
id: In(idArr),
|
||||||
...where,
|
...where,
|
||||||
@@ -94,7 +96,9 @@ export abstract class BaseService<T> {
|
|||||||
}
|
}
|
||||||
if (typeof ids === 'string') {
|
if (typeof ids === 'string') {
|
||||||
return ids.split(',');
|
return ids.split(',');
|
||||||
} else {
|
} else if(!Array.isArray(ids)){
|
||||||
|
return [ids];
|
||||||
|
}else {
|
||||||
return ids;
|
return ids;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -217,6 +221,7 @@ export abstract class BaseService<T> {
|
|||||||
if (!Array.isArray(ids)) {
|
if (!Array.isArray(ids)) {
|
||||||
ids = [ids];
|
ids = [ids];
|
||||||
}
|
}
|
||||||
|
ids = this.filterIds(ids);
|
||||||
const res = await this.getRepository().find({
|
const res = await this.getRepository().find({
|
||||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
@@ -234,7 +239,16 @@ export abstract class BaseService<T> {
|
|||||||
throw new PermissionException('权限不足');
|
throw new PermissionException('权限不足');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
filterIds(ids: any[]) {
|
||||||
|
if (!ids) {
|
||||||
|
throw new ValidateException('ids不能为空');
|
||||||
|
}
|
||||||
|
return ids.filter((item) => {
|
||||||
|
return item!=null && item != ""
|
||||||
|
});
|
||||||
|
}
|
||||||
async batchDelete(ids: number[], userId: number,projectId?:number) {
|
async batchDelete(ids: number[], userId: number,projectId?:number) {
|
||||||
|
ids = this.filterIds(ids);
|
||||||
if(userId!=null){
|
if(userId!=null){
|
||||||
const list = await this.getRepository().find({
|
const list = await this.getRepository().find({
|
||||||
where: {
|
where: {
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import yaml from "js-yaml";
|
|||||||
import { usePluginImport } from "./use-import";
|
import { usePluginImport } from "./use-import";
|
||||||
import { usePluginConfig } from "./use-config";
|
import { usePluginConfig } from "./use-config";
|
||||||
import { useSettingStore } from "/src/store/settings/index";
|
import { useSettingStore } from "/src/store/settings/index";
|
||||||
|
import { usePluginStore } from "/@/store/plugin";
|
||||||
|
|
||||||
export default function ({ crudExpose, context }: CreateCrudOptionsProps): CreateCrudOptionsRet {
|
export default function ({ crudExpose, context }: CreateCrudOptionsProps): CreateCrudOptionsRet {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
@@ -43,6 +44,7 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat
|
|||||||
const { openConfigDialog } = usePluginConfig();
|
const { openConfigDialog } = usePluginConfig();
|
||||||
|
|
||||||
const settingStore = useSettingStore();
|
const settingStore = useSettingStore();
|
||||||
|
const pluginStore = usePluginStore();
|
||||||
return {
|
return {
|
||||||
crudOptions: {
|
crudOptions: {
|
||||||
settings: {
|
settings: {
|
||||||
@@ -83,6 +85,15 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
table: {
|
||||||
|
rowKey: "name",
|
||||||
|
remove: {
|
||||||
|
afterRemove: async context => {
|
||||||
|
await pluginStore.reload();
|
||||||
|
},
|
||||||
|
confirmMessage: "确定要删除吗?如果该插件已被使用,删除可能会导致流水线执行失败!",
|
||||||
|
},
|
||||||
|
},
|
||||||
rowHandle: {
|
rowHandle: {
|
||||||
show: true,
|
show: true,
|
||||||
minWidth: 200,
|
minWidth: 200,
|
||||||
@@ -142,9 +153,6 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
table: {
|
|
||||||
rowKey: "name",
|
|
||||||
},
|
|
||||||
tabs: {
|
tabs: {
|
||||||
name: "type",
|
name: "type",
|
||||||
show: true,
|
show: true,
|
||||||
|
|||||||
@@ -58,7 +58,8 @@ export class PluginController extends CrudController<PluginService> {
|
|||||||
|
|
||||||
@Post('/delete', { description: 'sys:settings:edit' })
|
@Post('/delete', { description: 'sys:settings:edit' })
|
||||||
async delete(@Query('id') id: number) {
|
async delete(@Query('id') id: number) {
|
||||||
return super.deleteByIds([id]);
|
const res = await this.service.deleteByIds([id]);
|
||||||
|
return this.ok(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Post('/deleteByIds', { description: 'sys:settings:edit' })
|
@Post('/deleteByIds', { description: 'sys:settings:edit' })
|
||||||
|
|||||||
@@ -524,15 +524,12 @@ export class PluginService extends BaseService<PluginEntity> {
|
|||||||
id: pluginEntity.id
|
id: pluginEntity.id
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
async deleteByIds(ids: any[]) {
|
async deleteByIds(ids: any[]) {
|
||||||
|
ids = this.filterIds(ids);
|
||||||
for (const id of ids) {
|
for (const id of ids) {
|
||||||
await this.unRegisterById(id)
|
await this.unRegisterById(id);
|
||||||
await this.delete(id);
|
await this.delete(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user