diff --git a/packages/web/src/components/dynamic_form.tsx b/packages/web/src/components/dynamic_form.tsx index 6b808663..db6dc41b 100644 --- a/packages/web/src/components/dynamic_form.tsx +++ b/packages/web/src/components/dynamic_form.tsx @@ -22,7 +22,7 @@ export interface DynamicFormProps { setExpandedSections: (sections: Set) => void } -function EmptyTip ({ fields }: { fields: unknown[] }) { +function EmptyTip({ fields }: { fields: unknown[] }) { return ( fields.length === 0 && (
@@ -32,7 +32,7 @@ function EmptyTip ({ fields }: { fields: unknown[] }) { ) } -function ArrayField ({ +function ArrayField({ control, field, fullPath, @@ -89,7 +89,7 @@ function ArrayField ({ ) } -function ObjectArrayField ({ +function ObjectArrayField({ control, field, fullPath, @@ -153,7 +153,7 @@ const DynamicForm: React.FC = ({ errors, formConfig, expandedSections, - setExpandedSections + setExpandedSections, }) => { // 渲染表单字段 const renderField = (field: FormField, path: string = '') => { @@ -163,11 +163,7 @@ const DynamicForm: React.FC = ({ // 创建一个通用的描述渲染函数 const renderDescription = (description?: string) => { if (!description) return null - return ( -
- {description} -
- ) + return
{description}
} switch (field.type) { @@ -181,8 +177,9 @@ const DynamicForm: React.FC = ({ return ( { + onSelectionChange={keys => { if (typeof keys === 'string') { const newSet = new Set(expandedSections) if (newSet.has(field.key)) { @@ -196,11 +193,7 @@ const DynamicForm: React.FC = ({ } }} > - +
{field.children.map((subField, subIndex) => ( @@ -214,96 +207,95 @@ const DynamicForm: React.FC = ({ case 'text': return ( -
- - {renderDescription(field.description)} -
+ ) case 'number': return ( -
- - {renderDescription(field.description)} -
+ ) case 'switch': return ( -
- - {field.label} - + +
{field.label}
{renderDescription(field.description)} -
+ ) case 'checkbox': return ( -
+ {field.options.map(option => ( - + {option.label} ))} - {renderDescription(field.description)} -
+ ) case 'radio': return ( -
- - {field.options.map(option => ( - - {option.label} - - ))} - - {renderDescription(field.description)} -
+ + + + {field.options.map(option => ( + + {option.label} + + ))} + + + ) case 'select': return ( -
- - {renderDescription(field.description)} -
+ ) case 'array': @@ -335,9 +327,7 @@ const DynamicForm: React.FC = ({

{field.label}

{field.description && ( -
- {field.description} -
+
{field.description}
)}
diff --git a/packages/web/src/pages/dashboard/config.tsx b/packages/web/src/pages/dashboard/config.tsx index 6231b8a7..77c5c1d1 100644 --- a/packages/web/src/pages/dashboard/config.tsx +++ b/packages/web/src/pages/dashboard/config.tsx @@ -99,9 +99,9 @@ const ConfigPage: React.FC = () => { return (
-
+
{ -
+
{hasSections && (