diff --git a/packages/client/src/i18n/en.json b/packages/client/src/i18n/en.json index 533c005f..4d84c5b7 100644 --- a/packages/client/src/i18n/en.json +++ b/packages/client/src/i18n/en.json @@ -137,6 +137,8 @@ "value-name": "Value Name", "missing-value-name": "Missing value name", "check-only-number": "Only numbers can be entered", + "invalid-json": "Invalid JSON format", + "json-value-placeholder": "Enter JSON value, e.g. {\"key\": \"value\"}", "add-form-list-btn": "Add keyword argument" } }, diff --git a/packages/client/src/i18n/zh.json b/packages/client/src/i18n/zh.json index 44bb5645..093ee2d6 100644 --- a/packages/client/src/i18n/zh.json +++ b/packages/client/src/i18n/zh.json @@ -137,6 +137,8 @@ "value-name": "值名称", "missing-value-name": "缺少值名称", "check-only-number": "只能输入数字", + "invalid-json": "无效的 JSON 格式", + "json-value-placeholder": "输入 JSON 格式的值,例如 {\"key\": \"value\"}", "add-form-list-btn": "添加关键字参数" } }, diff --git a/packages/client/src/pages/FridayPage/SettingPage/KwargsFormList.tsx b/packages/client/src/pages/FridayPage/SettingPage/KwargsFormList.tsx index 6aa67f2a..45e96932 100644 --- a/packages/client/src/pages/FridayPage/SettingPage/KwargsFormList.tsx +++ b/packages/client/src/pages/FridayPage/SettingPage/KwargsFormList.tsx @@ -6,6 +6,8 @@ import { MinusCircleIcon, PlusCircleIcon } from 'lucide-react'; import { Button } from '@/components/ui/button.tsx'; import { inputTypeOptions, booleanOptions } from '../config'; +const { TextArea } = Input; + const KwargsFormList = ({ name }: { name: string }) => { const { t } = useTranslation(); const form = Form.useFormInstance(); @@ -19,7 +21,7 @@ const KwargsFormList = ({ name }: { name: string }) => { return ( - {({ getFieldValue, setFieldValue }) => ( + {({ setFieldValue }) => ( {(fields, { add, remove }) => ( <> @@ -112,72 +114,175 @@ const KwargsFormList = ({ name }: { name: string }) => { /> { + const prevType = + prevValues[name]?.[ + fieldName + ]?.type; + const currentType = + currentValues[name]?.[ + fieldName + ]?.type; + return ( + prevType !== currentType + ); + }} > - {getFieldValue([ - name, - fieldName, - 'type', - ]) === 'boolean' ? ( - { + newlyAddedRef.current.delete( + fieldName, + ); + }} + /> ); - }} - /> - ) : ( - { - newlyAddedRef.current.delete( - fieldName, + } else if ( + fieldType === 'json' + ) { + return ( +