From 8b26ae6532a35b6217787e797f88f6e57a7a5539 Mon Sep 17 00:00:00 2001 From: Joel Date: Tue, 24 Sep 2024 15:18:39 +0800 Subject: [PATCH] fix: http file node not added --- .../nodes/_base/hooks/use-one-step-run.ts | 2 ++ .../components/workflow/nodes/http/use-config.ts | 16 ++++++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/web/app/components/workflow/nodes/_base/hooks/use-one-step-run.ts b/web/app/components/workflow/nodes/_base/hooks/use-one-step-run.ts index 8876ab0058..af098dfe2e 100644 --- a/web/app/components/workflow/nodes/_base/hooks/use-one-step-run.ts +++ b/web/app/components/workflow/nodes/_base/hooks/use-one-step-run.ts @@ -80,6 +80,8 @@ const varTypeToInputVarType = (type: VarType, { return InputVarType.number if ([VarType.object, VarType.array, VarType.arrayNumber, VarType.arrayString, VarType.arrayObject].includes(type)) return InputVarType.json + if (type === VarType.file) + return InputVarType.singleFile if (type === VarType.arrayFile) return InputVarType.files diff --git a/web/app/components/workflow/nodes/http/use-config.ts b/web/app/components/workflow/nodes/http/use-config.ts index d49f199bb7..6e8d2e2ca2 100644 --- a/web/app/components/workflow/nodes/http/use-config.ts +++ b/web/app/components/workflow/nodes/http/use-config.ts @@ -1,4 +1,4 @@ -import { useCallback, useEffect, useState } from 'react' +import { useCallback, useEffect, useMemo, useState } from 'react' import produce from 'immer' import { useBoolean } from 'ahooks' import useVarList from '../_base/hooks/use-var-list' @@ -42,7 +42,7 @@ const useConfig = (id: string, payload: HttpNodeType) => { setInputs(newInputs) setIsDataReady(true) } - // eslint-disable-next-line react-hooks/exhaustive-deps + // eslint-disable-next-line react-hooks/exhaustive-deps }, [defaultConfig]) const handleMethodChange = useCallback((method: Method) => { @@ -132,11 +132,23 @@ const useConfig = (id: string, payload: HttpNodeType) => { defaultRunInputData: {}, }) + const fileVarInputs = useMemo(() => { + if (!Array.isArray(inputs.body.data)) + return '' + + const res = inputs.body.data + .filter(item => item.file?.length) + .map(item => item.file ? `{{#${item.file.join('.')}#}}` : '') + .join(' ') + return res + }, [inputs.body.data]) + const varInputs = getInputVars([ inputs.url, inputs.headers, inputs.params, typeof inputs.body.data === 'string' ? inputs.body.data : inputs.body.data.map(item => item.value).join(''), + fileVarInputs, ]) const inputVarValues = (() => {