mirror of
https://github.com/langgenius/dify.git
synced 2026-04-27 02:36:29 +08:00
fix: boolean problem
This commit is contained in:
parent
3ba23238e5
commit
657d3d1dae
@ -39,7 +39,7 @@ const ArrayValueList: FC<Props> = ({
|
|||||||
|
|
||||||
const handleItemAdd = useCallback(() => {
|
const handleItemAdd = useCallback(() => {
|
||||||
const newList = produce(list, (draft: any[]) => {
|
const newList = produce(list, (draft: any[]) => {
|
||||||
draft.push(undefined)
|
draft.push(true)
|
||||||
})
|
})
|
||||||
onChange(newList)
|
onChange(newList)
|
||||||
}, [list, onChange])
|
}, [list, onChange])
|
||||||
|
|||||||
@ -134,12 +134,16 @@ const ChatVariableModal = ({
|
|||||||
return value || ''
|
return value || ''
|
||||||
case ChatVarType.Number:
|
case ChatVarType.Number:
|
||||||
return value || 0
|
return value || 0
|
||||||
|
case ChatVarType.Boolean:
|
||||||
|
return value === undefined ? true : value
|
||||||
case ChatVarType.Object:
|
case ChatVarType.Object:
|
||||||
return editInJSON ? value : formatValueFromObject(objectValue)
|
return editInJSON ? value : formatValueFromObject(objectValue)
|
||||||
case ChatVarType.ArrayString:
|
case ChatVarType.ArrayString:
|
||||||
case ChatVarType.ArrayNumber:
|
case ChatVarType.ArrayNumber:
|
||||||
case ChatVarType.ArrayObject:
|
case ChatVarType.ArrayObject:
|
||||||
return value?.filter(Boolean) || []
|
return value?.filter(Boolean) || []
|
||||||
|
case ChatVarType.ArrayBoolean:
|
||||||
|
return value || []
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -218,6 +222,11 @@ const ChatVariableModal = ({
|
|||||||
setValue(value?.length ? value : [undefined])
|
setValue(value?.length ? value : [undefined])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(type === ChatVarType.ArrayBoolean) {
|
||||||
|
if(editInJSON)
|
||||||
|
setEditorContent(JSON.stringify(value.map((item: boolean) => item ? 'True' : 'False')))
|
||||||
|
}
|
||||||
setEditInJSON(editInJSON)
|
setEditInJSON(editInJSON)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -229,7 +238,16 @@ const ChatVariableModal = ({
|
|||||||
else {
|
else {
|
||||||
setEditorContent(content)
|
setEditorContent(content)
|
||||||
try {
|
try {
|
||||||
const newValue = JSON.parse(content)
|
let newValue = JSON.parse(content)
|
||||||
|
if(type === ChatVarType.ArrayBoolean) {
|
||||||
|
newValue = newValue.map((item: string) => {
|
||||||
|
if (item === 'True' || item === 'true')
|
||||||
|
return true
|
||||||
|
if (item === 'False' || item === 'false')
|
||||||
|
return false
|
||||||
|
return undefined
|
||||||
|
}).filter((item?: boolean) => item !== undefined)
|
||||||
|
}
|
||||||
setValue(newValue)
|
setValue(newValue)
|
||||||
}
|
}
|
||||||
catch {
|
catch {
|
||||||
@ -387,9 +405,9 @@ const ChatVariableModal = ({
|
|||||||
onChange={setValue}
|
onChange={setValue}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
{type === ChatVarType.ArrayNumber && !editInJSON && (
|
{type === ChatVarType.ArrayBoolean && !editInJSON && (
|
||||||
<ArrayBoolList
|
<ArrayBoolList
|
||||||
list={value}
|
list={value || [true]}
|
||||||
onChange={setValue}
|
onChange={setValue}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user