feat: add cURL import for http request node (#8656)

This commit is contained in:
非法操作
2024-11-21 22:25:18 +08:00
committed by GitHub
parent fefda40acf
commit 8b16f07eb0
5 changed files with 218 additions and 9 deletions

View File

@@ -164,6 +164,23 @@ const useConfig = (id: string, payload: HttpNodeType) => {
setRunInputData(newPayload)
}, [setRunInputData])
// curl import panel
const [isShowCurlPanel, {
setTrue: showCurlPanel,
setFalse: hideCurlPanel,
}] = useBoolean(false)
const handleCurlImport = useCallback((newNode: HttpNodeType) => {
const newInputs = produce(inputs, (draft: HttpNodeType) => {
draft.method = newNode.method
draft.url = newNode.url
draft.headers = newNode.headers
draft.params = newNode.params
draft.body = newNode.body
})
setInputs(newInputs)
}, [inputs, setInputs])
return {
readOnly,
isDataReady,
@@ -203,6 +220,11 @@ const useConfig = (id: string, payload: HttpNodeType) => {
inputVarValues,
setInputVarValues,
runResult,
// curl import
isShowCurlPanel,
showCurlPanel,
hideCurlPanel,
handleCurlImport,
}
}