Skip to content

Commit

Permalink
feat: support genshin competition register
Browse files Browse the repository at this point in the history
  • Loading branch information
dreamerblue committed Jan 26, 2024
1 parent 0ffc75e commit 54e7bbd
Show file tree
Hide file tree
Showing 11 changed files with 682 additions and 34 deletions.
2 changes: 1 addition & 1 deletion src/common
19 changes: 15 additions & 4 deletions src/components/GeneralForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export interface IGeneralFormItem {
// for select
value: string | number | boolean;
name: string;
icon?: React.ReactNode;
}[];
multiple?: boolean; // for select
transformBeforeSubmit?: (value) => any;
Expand Down Expand Up @@ -124,16 +125,26 @@ class GeneralForm extends React.Component<IGeneralFormProps, State> {
</Form.Item>
);
case 'select':
const useCustomMode = item.options.some((i) => !!i.icon);
return (
<Form.Item key={item.field} label={item.name}>
{getFieldDecorator(item.field, {
rules: item.rules,
initialValue: initialValues[item.field] || item.initialValue,
})(
<Select placeholder={item.placeholder} disabled={item.disabled} mode={item.multiple ? 'multiple' : undefined}>
{item.options.map((opt) => (
<Select.Option key={`${opt.value}`}>{opt.name}</Select.Option>
))}
<Select
placeholder={item.placeholder}
disabled={item.disabled}
mode={item.multiple ? 'multiple' : undefined}
optionLabelProp={useCustomMode ? 'label' : undefined}
>
{item.options.map((opt) =>
useCustomMode ? (
<Select.Option key={`${opt.value}`} value={`${opt.value}`} label={`${opt.name}`}>{opt.icon}{opt.name}</Select.Option>
) : (
<Select.Option key={`${opt.value}`}>{opt.name}</Select.Option>
),
)}
</Select>,
)}
</Form.Item>
Expand Down
Loading

0 comments on commit 54e7bbd

Please sign in to comment.