mirror of
https://github.com/langbot-app/LangBot.git
synced 2025-11-25 03:15:06 +08:00
38 lines
1.0 KiB
TypeScript
38 lines
1.0 KiB
TypeScript
import {Form, Input, InputNumber, Select, Switch} from "antd";
|
|
import {DynamicFormItemType, IDynamicFormItemConfig} from "@/app/home/components/dynamic-form/DynamicFormItemConfig";
|
|
|
|
export default function DynamicFormItemComponent({
|
|
config
|
|
}: {
|
|
config: IDynamicFormItemConfig
|
|
}) {
|
|
return (
|
|
<Form.Item
|
|
label={config.label.zh_CN}
|
|
name={config.name}
|
|
rules={[{required: config.required, message: "该项为必填项哦~"}]}
|
|
initialValue={config.default}
|
|
>
|
|
{
|
|
config.type === DynamicFormItemType.INT &&
|
|
<InputNumber/>
|
|
}
|
|
|
|
{
|
|
config.type === DynamicFormItemType.STRING &&
|
|
<Input/>
|
|
}
|
|
|
|
{
|
|
config.type === DynamicFormItemType.BOOLEAN &&
|
|
<Switch defaultChecked/>
|
|
}
|
|
|
|
{
|
|
config.type === DynamicFormItemType.STRING_ARRAY &&
|
|
<Select options={[]}/>
|
|
}
|
|
</Form.Item>
|
|
)
|
|
|
|
} |