From 843c8ad30644146202e4527b3c99e1cabb380eaa Mon Sep 17 00:00:00 2001 From: Joel Date: Fri, 9 Aug 2024 17:46:17 +0800 Subject: [PATCH] feat: file obj --- web/app/components/workflow/constants.ts | 15 +++++++++++++++ .../components/variable/var-reference-vars.tsx | 18 ++++++++++++++++-- 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/web/app/components/workflow/constants.ts b/web/app/components/workflow/constants.ts index 1f2c7b9116..e786579e14 100644 --- a/web/app/components/workflow/constants.ts +++ b/web/app/components/workflow/constants.ts @@ -427,6 +427,21 @@ export const PARAMETER_EXTRACTOR_COMMON_STRUCT: Var[] = [ }, ] +export const FILE_STRUCT: Var[] = [ + { + variable: 'name', + type: VarType.string, + }, + { + variable: 'size', + type: VarType.number, + }, + { + variable: 'type', + type: VarType.number, + }, +] + export const WORKFLOW_DATA_UPDATE = 'WORKFLOW_DATA_UPDATE' export const CUSTOM_NODE = 'custom' export const DSL_EXPORT_CHECK = 'DSL_EXPORT_CHECK' diff --git a/web/app/components/workflow/nodes/_base/components/variable/var-reference-vars.tsx b/web/app/components/workflow/nodes/_base/components/variable/var-reference-vars.tsx index c09172ce4e..6ef34a76ff 100644 --- a/web/app/components/workflow/nodes/_base/components/variable/var-reference-vars.tsx +++ b/web/app/components/workflow/nodes/_base/components/variable/var-reference-vars.tsx @@ -15,6 +15,7 @@ import { import Input from '@/app/components/base/input' import { Env } from '@/app/components/base/icons/src/vender/line/others' import { checkKeys } from '@/utils/var' +import { FILE_STRUCT } from '@/app/components/workflow/constants' type ObjectChildrenProps = { nodeId: string @@ -45,7 +46,8 @@ const Item: FC = ({ onHovering, itemWidth, }) => { - const isObj = itemData.type === VarType.object && itemData.children && itemData.children.length > 0 + const isObj = (itemData.type === VarType.object && itemData.children && itemData.children.length > 0) || itemData.type === VarType.file + const isFile = itemData.type === VarType.file const isSys = itemData.variable.startsWith('sys.') const isEnv = itemData.variable.startsWith('env.') const itemRef = useRef(null) @@ -114,7 +116,7 @@ const Item: FC = ({ - {isObj && ( + {(isObj && !isFile) && ( // eslint-disable-next-line @typescript-eslint/no-use-before-define = ({ itemWidth={itemWidth} /> )} + {isFile && ( + // eslint-disable-next-line @typescript-eslint/no-use-before-define + + )} )