feat: file obj

This commit is contained in:
Joel 2024-08-09 17:46:17 +08:00
parent 594bf96922
commit 843c8ad306
2 changed files with 31 additions and 2 deletions

View File

@ -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 WORKFLOW_DATA_UPDATE = 'WORKFLOW_DATA_UPDATE'
export const CUSTOM_NODE = 'custom' export const CUSTOM_NODE = 'custom'
export const DSL_EXPORT_CHECK = 'DSL_EXPORT_CHECK' export const DSL_EXPORT_CHECK = 'DSL_EXPORT_CHECK'

View File

@ -15,6 +15,7 @@ import {
import Input from '@/app/components/base/input' import Input from '@/app/components/base/input'
import { Env } from '@/app/components/base/icons/src/vender/line/others' import { Env } from '@/app/components/base/icons/src/vender/line/others'
import { checkKeys } from '@/utils/var' import { checkKeys } from '@/utils/var'
import { FILE_STRUCT } from '@/app/components/workflow/constants'
type ObjectChildrenProps = { type ObjectChildrenProps = {
nodeId: string nodeId: string
@ -45,7 +46,8 @@ const Item: FC<ItemProps> = ({
onHovering, onHovering,
itemWidth, 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 isSys = itemData.variable.startsWith('sys.')
const isEnv = itemData.variable.startsWith('env.') const isEnv = itemData.variable.startsWith('env.')
const itemRef = useRef(null) const itemRef = useRef(null)
@ -114,7 +116,7 @@ const Item: FC<ItemProps> = ({
<PortalToFollowElemContent style={{ <PortalToFollowElemContent style={{
zIndex: 100, zIndex: 100,
}}> }}>
{isObj && ( {(isObj && !isFile) && (
// eslint-disable-next-line @typescript-eslint/no-use-before-define // eslint-disable-next-line @typescript-eslint/no-use-before-define
<ObjectChildren <ObjectChildren
nodeId={nodeId} nodeId={nodeId}
@ -126,6 +128,18 @@ const Item: FC<ItemProps> = ({
itemWidth={itemWidth} itemWidth={itemWidth}
/> />
)} )}
{isFile && (
// eslint-disable-next-line @typescript-eslint/no-use-before-define
<ObjectChildren
nodeId={nodeId}
title={title}
objPath={[...objPath, itemData.variable]}
data={FILE_STRUCT}
onChange={onChange}
onHovering={setIsChildrenHovering}
itemWidth={itemWidth}
/>
)}
</PortalToFollowElemContent> </PortalToFollowElemContent>
</PortalToFollowElem> </PortalToFollowElem>
) )