mirror of https://github.com/langgenius/dify.git
fix: http json value would changed
This commit is contained in:
parent
de3fd0f382
commit
85b45a7cd0
|
|
@ -61,7 +61,7 @@ const EditBody: FC<Props> = ({
|
|||
draft.data = value
|
||||
})
|
||||
onChange(newBody)
|
||||
})
|
||||
}, type === BodyType.json)
|
||||
|
||||
const isCurrentKeyValue = type === BodyType.formData || type === BodyType.xWwwFormUrlencoded
|
||||
|
||||
|
|
|
|||
|
|
@ -9,15 +9,17 @@ const strToKeyValueList = (value: string) => {
|
|||
})
|
||||
}
|
||||
|
||||
const useKeyValueList = (value: string, onChange: (value: string) => void) => {
|
||||
const useKeyValueList = (value: string, onChange: (value: string) => void, noFilter?: boolean) => {
|
||||
const [list, setList] = useState<KeyValue[]>(value ? strToKeyValueList(value) : [])
|
||||
useEffect(() => {
|
||||
if (noFilter)
|
||||
return
|
||||
const newValue = list.filter(item => item.key && item.value).map(item => `${item.key}:${item.value}`).join('\n')
|
||||
if (newValue !== value)
|
||||
onChange(newValue)
|
||||
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [list])
|
||||
}, [list, noFilter])
|
||||
const addItem = useCallback(() => {
|
||||
setList(prev => [...prev, { key: '', value: '' }])
|
||||
}, [])
|
||||
|
|
|
|||
Loading…
Reference in New Issue