Initial commit

This commit is contained in:
shiyu
2025-08-24 18:49:00 +08:00
parent 99866befe1
commit 6b0f2bd4fa
129 changed files with 11587 additions and 0 deletions

View File

@@ -0,0 +1,61 @@
import React from 'react';
import { Form, Input, Select, Typography } from 'antd';
import type { ProcessorTypeMeta } from '../api/processors';
interface ProcessorConfigFormProps {
processorMeta: ProcessorTypeMeta | undefined;
form: any;
configPath: string[];
}
export const ProcessorConfigForm: React.FC<ProcessorConfigFormProps> = ({ processorMeta, configPath }) => {
if (!processorMeta) {
return <Typography.Text type="secondary"></Typography.Text>;
}
if (!processorMeta.config_schema?.length) {
return <Typography.Text type="secondary"></Typography.Text>;
}
return (
<>
{processorMeta.config_schema.map(field => {
const rules = field.required ? [{ required: true, message: `请输入${field.label}` }] : [];
let inputNode: React.ReactNode;
switch (field.type) {
case 'password':
inputNode = <Input.Password placeholder={field.placeholder} />;
break;
case 'number':
inputNode = <Input type="number" placeholder={field.placeholder} />;
break;
case 'select':
inputNode = (
<Select placeholder={field.placeholder || '请选择'}>
{field.options?.map((opt: any) => (
<Select.Option key={String(opt.value)} value={opt.value}>
{opt.label}
</Select.Option>
))}
</Select>
);
break;
default:
inputNode = <Input placeholder={field.placeholder} />;
}
return (
<Form.Item
key={field.key}
name={[...configPath, field.key]}
label={field.label}
rules={rules}
initialValue={field.default}
>
{inputNode}
</Form.Item>
);
})}
</>
);
};