Merge pull request #850 from SuanmoSuanyangTechnology/feature/tool_zy

feat(web): start/chat variable name cannot be duplicated
This commit is contained in:
yingzhao
2026-04-09 22:43:55 +08:00
committed by GitHub
6 changed files with 25 additions and 5 deletions

View File

@@ -2453,7 +2453,8 @@ Memory Bear: After the rebellion, regional warlordism intensified for several re
value: 'Value', value: 'Value',
addCase: 'Add Condition', addCase: 'Add Condition',
addVariable: 'Add Variables', addVariable: 'Add Variables',
output: 'Output Variable' output: 'Output Variable',
duplicateName: 'Variable name cannot be duplicated',
}, },
clear: 'Clear', clear: 'Clear',
@@ -2480,7 +2481,7 @@ Memory Bear: After the rebellion, regional warlordism intensified for several re
input_cycle_vars: 'Initial Loop Variables', input_cycle_vars: 'Initial Loop Variables',
output_cycle_vars: 'Final Loop Variables', output_cycle_vars: 'Final Loop Variables',
}, },
sureReplace: '确认替换', sureReplace: 'Confirm Replace',
checkList: 'Check List', checkList: 'Check List',
checkListDesc: 'Ensure all issues are resolved before publishing', checkListDesc: 'Ensure all issues are resolved before publishing',
checkListEmpty: 'No issues found', checkListEmpty: 'No issues found',

View File

@@ -2417,7 +2417,8 @@ export const zh = {
value: '值', value: '值',
addCase: '添加条件', addCase: '添加条件',
addVariable: '添加变量', addVariable: '添加变量',
output: '输出变量' output: '输出变量',
duplicateName: '变量名不能重复',
}, },
clear: '清空', clear: '清空',

View File

@@ -45,6 +45,7 @@ const array_object_placeholder = `# example
interface ChatVariableModalProps { interface ChatVariableModalProps {
refresh: (value: ChatVariable, editIndex?: number) => void; refresh: (value: ChatVariable, editIndex?: number) => void;
variables?: ChatVariable[];
} }
const types = [ const types = [
@@ -61,7 +62,8 @@ const types = [
] ]
const ChatVariableModal = forwardRef<ChatVariableModalRef, ChatVariableModalProps>(({ const ChatVariableModal = forwardRef<ChatVariableModalRef, ChatVariableModalProps>(({
refresh refresh,
variables
}, ref) => { }, ref) => {
const { t } = useTranslation(); const { t } = useTranslation();
const uploadFileListModalRef = useRef<UploadFileListModalRef>(null); const uploadFileListModalRef = useRef<UploadFileListModalRef>(null);
@@ -244,6 +246,12 @@ const ChatVariableModal = forwardRef<ChatVariableModalRef, ChatVariableModalProp
rules={[ rules={[
{ required: true, message: t('common.pleaseEnter') }, { required: true, message: t('common.pleaseEnter') },
{ pattern: /^[a-zA-Z_][a-zA-Z0-9_]*$/, message: t('workflow.config.parameter-extractor.invalidParamName') }, { pattern: /^[a-zA-Z_][a-zA-Z0-9_]*$/, message: t('workflow.config.parameter-extractor.invalidParamName') },
{
validator: (_, value) => {
const duplicate = variables?.some((v, i) => v.name === value && i !== editIndex);
return duplicate ? Promise.reject(t('workflow.config.duplicateName')) : Promise.resolve();
}
},
]} ]}
> >
<Input placeholder={t('common.enter')} /> <Input placeholder={t('common.enter')} />

View File

@@ -104,6 +104,7 @@ const AddChatVariable = forwardRef<AddChatVariableRef, AddChatVariableProps>(({
<ChatVariableModal <ChatVariableModal
ref={chatVariableRef} ref={chatVariableRef}
refresh={handleSave} refresh={handleSave}
variables={variables}
/> />
</RbDrawer> </RbDrawer>
); );

View File

@@ -10,6 +10,7 @@ const FormItem = Form.Item;
interface VariableEditModalProps { interface VariableEditModalProps {
refresh: (values: Variable) => void; refresh: (values: Variable) => void;
variables?: Variable[];
} }
const types = [ const types = [
@@ -32,7 +33,8 @@ const initialValues = {
} }
const VariableEditModal = forwardRef<VariableEditModalRef, VariableEditModalProps>(({ const VariableEditModal = forwardRef<VariableEditModalRef, VariableEditModalProps>(({
refresh refresh,
variables
}, ref) => { }, ref) => {
const { t } = useTranslation(); const { t } = useTranslation();
const [visible, setVisible] = useState(false); const [visible, setVisible] = useState(false);
@@ -123,6 +125,12 @@ const VariableEditModal = forwardRef<VariableEditModalRef, VariableEditModalProp
rules={[ rules={[
{ required: true, message: t('common.pleaseEnter') }, { required: true, message: t('common.pleaseEnter') },
{ pattern: /^[a-zA-Z_][a-zA-Z0-9_]*$/, message: t('workflow.config.start.invalidVariableName') }, { pattern: /^[a-zA-Z_][a-zA-Z0-9_]*$/, message: t('workflow.config.start.invalidVariableName') },
{
validator: (_, value) => {
const duplicate = variables?.some(v => v.name === value && v.name !== editVo?.name);
return duplicate ? Promise.reject(t('workflow.config.duplicateName')) : Promise.resolve();
}
},
]} ]}
> >
<Input placeholder={t('common.enter')} onBlur={nameChange} /> <Input placeholder={t('common.enter')} onBlur={nameChange} />

View File

@@ -104,6 +104,7 @@ const VariableList: FC<VariableListProps> = ({
<VariableEditModal <VariableEditModal
ref={variableModalRef} ref={variableModalRef}
refresh={handleRefreshVariable} refresh={handleRefreshVariable}
variables={value}
/> />
</div> </div>
) )