mirror of
https://github.com/langgenius/dify.git
synced 2026-04-24 00:59:19 +08:00
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
|
draft.data = value
|
||||||
})
|
})
|
||||||
onChange(newBody)
|
onChange(newBody)
|
||||||
})
|
}, type === BodyType.json)
|
||||||
|
|
||||||
const isCurrentKeyValue = type === BodyType.formData || type === BodyType.xWwwFormUrlencoded
|
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) : [])
|
const [list, setList] = useState<KeyValue[]>(value ? strToKeyValueList(value) : [])
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
if (noFilter)
|
||||||
|
return
|
||||||
const newValue = list.filter(item => item.key && item.value).map(item => `${item.key}:${item.value}`).join('\n')
|
const newValue = list.filter(item => item.key && item.value).map(item => `${item.key}:${item.value}`).join('\n')
|
||||||
if (newValue !== value)
|
if (newValue !== value)
|
||||||
onChange(newValue)
|
onChange(newValue)
|
||||||
|
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, [list])
|
}, [list, noFilter])
|
||||||
const addItem = useCallback(() => {
|
const addItem = useCallback(() => {
|
||||||
setList(prev => [...prev, { key: '', value: '' }])
|
setList(prev => [...prev, { key: '', value: '' }])
|
||||||
}, [])
|
}, [])
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user