mirror of
https://github.com/langgenius/dify.git
synced 2025-12-04 14:56:42 +00:00
fix(variable): ensure unique variable names in var-list (#22038)
This commit is contained in:
parent
f62b59a805
commit
f925869f61
@ -75,8 +75,16 @@ const VarList: FC<Props> = ({
|
||||
if (isSupportConstantValue)
|
||||
draft[index].variable_type = VarKindType.variable
|
||||
|
||||
if (!draft[index].variable)
|
||||
draft[index].variable = value[value.length - 1]
|
||||
if (!draft[index].variable) {
|
||||
const variables = draft.map(v => v.variable)
|
||||
let newVarName = value[value.length - 1]
|
||||
let count = 1
|
||||
while (variables.includes(newVarName)) {
|
||||
newVarName = `${value[value.length - 1]}_${count}`
|
||||
count++
|
||||
}
|
||||
draft[index].variable = newVarName
|
||||
}
|
||||
}
|
||||
else {
|
||||
draft[index].variable_type = VarKindType.constant
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user