From 4816d2346b20cd14c6971378959147a072cbb6d4 Mon Sep 17 00:00:00 2001 From: heheer Date: Wed, 16 Jul 2025 14:36:27 +0800 Subject: [PATCH] compatible with old enums\ (#5221) --- projects/app/src/components/core/app/VariableEdit.tsx | 2 +- projects/app/src/components/core/app/formRender/index.tsx | 7 +++++-- projects/app/src/components/core/app/formRender/type.d.ts | 3 +++ 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/projects/app/src/components/core/app/VariableEdit.tsx b/projects/app/src/components/core/app/VariableEdit.tsx index 3ea40a800..7cdeeacf6 100644 --- a/projects/app/src/components/core/app/VariableEdit.tsx +++ b/projects/app/src/components/core/app/VariableEdit.tsx @@ -385,7 +385,7 @@ const TableItem = ({ onClick={() => { const formattedItem = { ...item, - list: item.enums || [] + list: item.enums?.map((item) => ({ label: item.value, value: item.value })) || [] }; reset(formattedItem); }} diff --git a/projects/app/src/components/core/app/formRender/index.tsx b/projects/app/src/components/core/app/formRender/index.tsx index a4b04e718..eb751e467 100644 --- a/projects/app/src/components/core/app/formRender/index.tsx +++ b/projects/app/src/components/core/app/formRender/index.tsx @@ -100,11 +100,14 @@ const InputRender = (props: InputRenderProps) => { } if (inputType === InputTypeEnum.select) { - return ; + const list = + props.list || props.enums?.map((item) => ({ label: item.value, value: item.value })) || []; + return ; } if (inputType === InputTypeEnum.multipleSelect) { - const { list = [] } = props; + const list = + props.list || props.enums?.map((item) => ({ label: item.value, value: item.value })) || []; return ( {...commonProps} diff --git a/projects/app/src/components/core/app/formRender/type.d.ts b/projects/app/src/components/core/app/formRender/type.d.ts index a31fcab5b..e8462c8c8 100644 --- a/projects/app/src/components/core/app/formRender/type.d.ts +++ b/projects/app/src/components/core/app/formRender/type.d.ts @@ -40,6 +40,9 @@ type SpecificProps = // select & multipleSelect inputType: InputTypeEnum.select | InputTypeEnum.multipleSelect; list?: { label: string; value: string }[]; + + // old version + enums?: { value: string }[]; } | { // JSONEditor