From 0e60da6d8ac31c869f8a04288b0a94384cdaab43 Mon Sep 17 00:00:00 2001 From: zhaoying Date: Thu, 9 Apr 2026 22:42:27 +0800 Subject: [PATCH] feat(web): start/chat variable name cannot be duplicated --- web/src/i18n/en.ts | 5 +++-- web/src/i18n/zh.ts | 3 ++- .../components/AddChatVariable/ChatVariableModal.tsx | 10 +++++++++- .../Workflow/components/AddChatVariable/index.tsx | 1 + .../Properties/VariableList/VariableEditModal.tsx | 10 +++++++++- .../components/Properties/VariableList/index.tsx | 1 + 6 files changed, 25 insertions(+), 5 deletions(-) diff --git a/web/src/i18n/en.ts b/web/src/i18n/en.ts index 8f88b561..3d24c0d0 100644 --- a/web/src/i18n/en.ts +++ b/web/src/i18n/en.ts @@ -2453,7 +2453,8 @@ Memory Bear: After the rebellion, regional warlordism intensified for several re value: 'Value', addCase: 'Add Condition', addVariable: 'Add Variables', - output: 'Output Variable' + output: 'Output Variable', + duplicateName: 'Variable name cannot be duplicated', }, clear: 'Clear', @@ -2480,7 +2481,7 @@ Memory Bear: After the rebellion, regional warlordism intensified for several re input_cycle_vars: 'Initial Loop Variables', output_cycle_vars: 'Final Loop Variables', }, - sureReplace: '确认替换', + sureReplace: 'Confirm Replace', checkList: 'Check List', checkListDesc: 'Ensure all issues are resolved before publishing', checkListEmpty: 'No issues found', diff --git a/web/src/i18n/zh.ts b/web/src/i18n/zh.ts index e521d5fa..f5e3653a 100644 --- a/web/src/i18n/zh.ts +++ b/web/src/i18n/zh.ts @@ -2417,7 +2417,8 @@ export const zh = { value: '值', addCase: '添加条件', addVariable: '添加变量', - output: '输出变量' + output: '输出变量', + duplicateName: '变量名不能重复', }, clear: '清空', diff --git a/web/src/views/Workflow/components/AddChatVariable/ChatVariableModal.tsx b/web/src/views/Workflow/components/AddChatVariable/ChatVariableModal.tsx index 604195f7..ff773a9e 100644 --- a/web/src/views/Workflow/components/AddChatVariable/ChatVariableModal.tsx +++ b/web/src/views/Workflow/components/AddChatVariable/ChatVariableModal.tsx @@ -45,6 +45,7 @@ const array_object_placeholder = `# example interface ChatVariableModalProps { refresh: (value: ChatVariable, editIndex?: number) => void; + variables?: ChatVariable[]; } const types = [ @@ -61,7 +62,8 @@ const types = [ ] const ChatVariableModal = forwardRef(({ - refresh + refresh, + variables }, ref) => { const { t } = useTranslation(); const uploadFileListModalRef = useRef(null); @@ -244,6 +246,12 @@ const ChatVariableModal = forwardRef { + const duplicate = variables?.some((v, i) => v.name === value && i !== editIndex); + return duplicate ? Promise.reject(t('workflow.config.duplicateName')) : Promise.resolve(); + } + }, ]} > diff --git a/web/src/views/Workflow/components/AddChatVariable/index.tsx b/web/src/views/Workflow/components/AddChatVariable/index.tsx index d7ab5cee..07e070d9 100644 --- a/web/src/views/Workflow/components/AddChatVariable/index.tsx +++ b/web/src/views/Workflow/components/AddChatVariable/index.tsx @@ -104,6 +104,7 @@ const AddChatVariable = forwardRef(({ ); diff --git a/web/src/views/Workflow/components/Properties/VariableList/VariableEditModal.tsx b/web/src/views/Workflow/components/Properties/VariableList/VariableEditModal.tsx index 7a3af15d..3282b0d2 100644 --- a/web/src/views/Workflow/components/Properties/VariableList/VariableEditModal.tsx +++ b/web/src/views/Workflow/components/Properties/VariableList/VariableEditModal.tsx @@ -10,6 +10,7 @@ const FormItem = Form.Item; interface VariableEditModalProps { refresh: (values: Variable) => void; + variables?: Variable[]; } const types = [ @@ -32,7 +33,8 @@ const initialValues = { } const VariableEditModal = forwardRef(({ - refresh + refresh, + variables }, ref) => { const { t } = useTranslation(); const [visible, setVisible] = useState(false); @@ -123,6 +125,12 @@ const VariableEditModal = forwardRef { + const duplicate = variables?.some(v => v.name === value && v.name !== editVo?.name); + return duplicate ? Promise.reject(t('workflow.config.duplicateName')) : Promise.resolve(); + } + }, ]} > diff --git a/web/src/views/Workflow/components/Properties/VariableList/index.tsx b/web/src/views/Workflow/components/Properties/VariableList/index.tsx index 6ff545eb..8046c07e 100644 --- a/web/src/views/Workflow/components/Properties/VariableList/index.tsx +++ b/web/src/views/Workflow/components/Properties/VariableList/index.tsx @@ -104,6 +104,7 @@ const VariableList: FC = ({ )