mirror of https://github.com/certd/certd
refactor(plugin): 优化插件配置界面和功能
-调整插件配置界面布局和样式 - 增加插件类型和图标字段 - 修改字段显示逻辑,根据不同插件类型显示相应字段 - 优化插件服务端处理逻辑,支持不同类型的插件配置pull/370/head
parent
3d8a5196a0
commit
88134ac130
|
@ -42,16 +42,16 @@ import { merge } from "lodash-es";
|
||||||
import { notification } from "ant-design-vue";
|
import { notification } from "ant-design-vue";
|
||||||
|
|
||||||
defineOptions({
|
defineOptions({
|
||||||
name: "SysPluginConfig"
|
name: "SysPluginConfig",
|
||||||
});
|
});
|
||||||
const formState = reactive<Partial<CommPluginConfig>>({
|
const formState = reactive<Partial<CommPluginConfig>>({
|
||||||
CertApply: {
|
CertApply: {
|
||||||
sysSetting: {
|
sysSetting: {
|
||||||
input: {
|
input: {
|
||||||
googleCommonEabAccessId: null
|
googleCommonEabAccessId: null,
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
async function loadForm() {
|
async function loadForm() {
|
||||||
|
@ -67,7 +67,7 @@ const onFinish = async (form: any) => {
|
||||||
saveLoading.value = true;
|
saveLoading.value = true;
|
||||||
await SaveCommPluginConfigs(form);
|
await SaveCommPluginConfigs(form);
|
||||||
notification.success({
|
notification.success({
|
||||||
message: "保存成功"
|
message: "保存成功",
|
||||||
});
|
});
|
||||||
} finally {
|
} finally {
|
||||||
saveLoading.value = false;
|
saveLoading.value = false;
|
||||||
|
|
|
@ -110,6 +110,54 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat
|
||||||
// show: false
|
// show: false
|
||||||
// }
|
// }
|
||||||
// },
|
// },
|
||||||
|
pluginType: {
|
||||||
|
title: "插件类型",
|
||||||
|
type: "dict-select",
|
||||||
|
search: {
|
||||||
|
show: true,
|
||||||
|
},
|
||||||
|
form: {
|
||||||
|
order: 0,
|
||||||
|
rules: [{ required: true }],
|
||||||
|
},
|
||||||
|
editForm: {
|
||||||
|
component: {
|
||||||
|
disabled: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
dict: dict({
|
||||||
|
data: [
|
||||||
|
{ label: "授权", value: "access" },
|
||||||
|
{ label: "DNS", value: "dnsProvider" },
|
||||||
|
{ label: "部署插件", value: "deploy" },
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
column: {
|
||||||
|
width: 100,
|
||||||
|
align: "center",
|
||||||
|
component: {
|
||||||
|
color: "auto",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
icon: {
|
||||||
|
title: "图标",
|
||||||
|
type: "icon",
|
||||||
|
form: {
|
||||||
|
rules: [{ required: true }],
|
||||||
|
},
|
||||||
|
column: {
|
||||||
|
width: 70,
|
||||||
|
align: "center",
|
||||||
|
component: {
|
||||||
|
name: "fs-icon",
|
||||||
|
vModel: "icon",
|
||||||
|
style: {
|
||||||
|
fontSize: "22px",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
name: {
|
name: {
|
||||||
title: "插件名称",
|
title: "插件名称",
|
||||||
type: "text",
|
type: "text",
|
||||||
|
@ -118,7 +166,6 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat
|
||||||
},
|
},
|
||||||
form: {
|
form: {
|
||||||
show: true,
|
show: true,
|
||||||
order: 0,
|
|
||||||
helper: "必须为英文,驼峰命名,类型作为前缀\n例如AliyunDeployToCDN\n插件一旦被使用,不要修改名称",
|
helper: "必须为英文,驼峰命名,类型作为前缀\n例如AliyunDeployToCDN\n插件一旦被使用,不要修改名称",
|
||||||
rules: [{ required: true }],
|
rules: [{ required: true }],
|
||||||
},
|
},
|
||||||
|
@ -141,7 +188,6 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat
|
||||||
},
|
},
|
||||||
form: {
|
form: {
|
||||||
show: true,
|
show: true,
|
||||||
order: 0,
|
|
||||||
helper: "上传到插件商店时,将作为插件名称前缀,例如:greper/pluginName",
|
helper: "上传到插件商店时,将作为插件名称前缀,例如:greper/pluginName",
|
||||||
rules: [{ required: true }],
|
rules: [{ required: true }],
|
||||||
},
|
},
|
||||||
|
@ -150,30 +196,10 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat
|
||||||
show: false,
|
show: false,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
icon: {
|
|
||||||
title: "图标",
|
|
||||||
type: "icon",
|
|
||||||
form: {
|
|
||||||
rules: [{ required: true }],
|
|
||||||
},
|
|
||||||
column: {
|
|
||||||
width: 70,
|
|
||||||
align: "center",
|
|
||||||
component: {
|
|
||||||
name: "fs-icon",
|
|
||||||
vModel: "icon",
|
|
||||||
style: {
|
|
||||||
fontSize: "22px",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
title: {
|
title: {
|
||||||
title: "标题",
|
title: "标题",
|
||||||
type: "text",
|
type: "text",
|
||||||
form: {
|
form: {
|
||||||
order: 0,
|
|
||||||
helper: "插件中文名称",
|
helper: "插件中文名称",
|
||||||
rules: [{ required: true }],
|
rules: [{ required: true }],
|
||||||
},
|
},
|
||||||
|
@ -196,6 +222,7 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat
|
||||||
show: false,
|
show: false,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
type: {
|
type: {
|
||||||
title: "来源",
|
title: "来源",
|
||||||
type: "dict-select",
|
type: "dict-select",
|
||||||
|
@ -223,35 +250,6 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
pluginType: {
|
|
||||||
title: "插件类型",
|
|
||||||
type: "dict-select",
|
|
||||||
search: {
|
|
||||||
show: true,
|
|
||||||
},
|
|
||||||
form: {
|
|
||||||
rules: [{ required: true }],
|
|
||||||
},
|
|
||||||
editForm: {
|
|
||||||
component: {
|
|
||||||
disabled: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
dict: dict({
|
|
||||||
data: [
|
|
||||||
{ label: "授权", value: "access" },
|
|
||||||
{ label: "DNS", value: "dnsProvider" },
|
|
||||||
{ label: "部署插件", value: "deploy" },
|
|
||||||
],
|
|
||||||
}),
|
|
||||||
column: {
|
|
||||||
width: 100,
|
|
||||||
align: "center",
|
|
||||||
component: {
|
|
||||||
color: "auto",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
version: {
|
version: {
|
||||||
title: "版本",
|
title: "版本",
|
||||||
type: "text",
|
type: "text",
|
||||||
|
@ -260,25 +258,6 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat
|
||||||
align: "center",
|
align: "center",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
group: {
|
|
||||||
title: "分组",
|
|
||||||
type: "dict-select",
|
|
||||||
dict: dict({
|
|
||||||
url: "/pi/plugin/groupsList",
|
|
||||||
label: "title",
|
|
||||||
value: "key",
|
|
||||||
}),
|
|
||||||
form: {
|
|
||||||
rules: [{ required: true }],
|
|
||||||
},
|
|
||||||
column: {
|
|
||||||
width: 100,
|
|
||||||
align: "left",
|
|
||||||
component: {
|
|
||||||
color: "auto",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"extra.dependLibs": {
|
"extra.dependLibs": {
|
||||||
title: "第三方依赖",
|
title: "第三方依赖",
|
||||||
type: "text",
|
type: "text",
|
||||||
|
@ -316,8 +295,8 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat
|
||||||
type: "dict-switch",
|
type: "dict-switch",
|
||||||
dict: dict({
|
dict: dict({
|
||||||
data: [
|
data: [
|
||||||
{ value: false, label: "不可修改" },
|
|
||||||
{ value: true, label: "可修改" },
|
{ value: true, label: "可修改" },
|
||||||
|
{ value: false, label: "不可修改" },
|
||||||
],
|
],
|
||||||
}),
|
}),
|
||||||
form: {
|
form: {
|
||||||
|
@ -404,6 +383,28 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
group: {
|
||||||
|
title: "插件分组",
|
||||||
|
type: "dict-select",
|
||||||
|
dict: dict({
|
||||||
|
url: "/pi/plugin/groupsList",
|
||||||
|
label: "title",
|
||||||
|
value: "key",
|
||||||
|
}),
|
||||||
|
form: {
|
||||||
|
rules: [{ required: true }],
|
||||||
|
show: compute(({ form }) => {
|
||||||
|
return form.pluginType === "deploy";
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
column: {
|
||||||
|
width: 100,
|
||||||
|
align: "left",
|
||||||
|
component: {
|
||||||
|
color: "auto",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
createTime: {
|
createTime: {
|
||||||
title: "创建时间",
|
title: "创建时间",
|
||||||
type: "datetime",
|
type: "datetime",
|
||||||
|
|
|
@ -24,11 +24,11 @@ input:
|
||||||
`
|
`
|
||||||
|
|
||||||
const script = `
|
const script = `
|
||||||
# 必须使用 await import 来引入模块
|
// 必须使用 await import 来引入模块
|
||||||
const { BaseAccess } = await import("@certd/pipeline")
|
const { BaseAccess } = await import("@certd/pipeline")
|
||||||
# 需要返回一个继承BaseAccess的类
|
// 需要返回一个继承BaseAccess的类
|
||||||
return class DemoAccess extends BaseAccess {
|
return class DemoAccess extends BaseAccess {
|
||||||
# 授权的字段,跟左边input一一对应
|
// 授权的字段,跟左边input一一对应
|
||||||
username;
|
username;
|
||||||
password;
|
password;
|
||||||
}
|
}
|
||||||
|
@ -109,7 +109,7 @@ return class DemoTask extends AbstractTaskPlugin {
|
||||||
key2;
|
key2;
|
||||||
// 编写执行方法
|
// 编写执行方法
|
||||||
async execute(){
|
async execute(){
|
||||||
# 根据accessId获取授权配置
|
// 根据accessId获取授权配置
|
||||||
const access = await this.getAccess(this.accessId)
|
const access = await this.getAccess(this.accessId)
|
||||||
|
|
||||||
//必须使用this.logger打印日志
|
//必须使用this.logger打印日志
|
||||||
|
|
|
@ -166,10 +166,12 @@ export class PluginService extends BaseService<PluginEntity> {
|
||||||
let plugin:any = {}
|
let plugin:any = {}
|
||||||
if (param.pluginType === "access") {
|
if (param.pluginType === "access") {
|
||||||
plugin = getDefaultAccessPlugin()
|
plugin = getDefaultAccessPlugin()
|
||||||
|
delete param.group
|
||||||
}else if (param.pluginType === "deploy") {
|
}else if (param.pluginType === "deploy") {
|
||||||
plugin = getDefaultDeployPlugin()
|
plugin = getDefaultDeployPlugin()
|
||||||
}else if (param.pluginType === "dnsProvider") {
|
}else if (param.pluginType === "dnsProvider") {
|
||||||
plugin = getDefaultDnsPlugin()
|
plugin = getDefaultDnsPlugin()
|
||||||
|
delete param.group
|
||||||
}else{
|
}else{
|
||||||
throw new Error(`插件类型${param.pluginType}不支持`);
|
throw new Error(`插件类型${param.pluginType}不支持`);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue