feat: var type to inner

This commit is contained in:
Joel 2025-06-04 17:34:12 +08:00
parent c9a4c66b07
commit 0bf0c7dbe8
5 changed files with 27 additions and 43 deletions

View File

@ -4,7 +4,7 @@ import { useNodes } from 'reactflow'
import { useTranslation } from 'react-i18next'
import NodeVariableItem from '../variable-assigner/components/node-variable-item'
import type { AssignerNodeType } from './types'
import { isConversationVar, isENV, isSystemVar } from '@/app/components/workflow/nodes/_base/components/variable/utils'
import { isSystemVar } from '@/app/components/workflow/nodes/_base/components/variable/utils'
import { BlockEnum, type Node, type NodeProps } from '@/app/components/workflow/types'
const i18nPrefix = 'workflow.nodes.assigner'
@ -38,18 +38,13 @@ const NodeComponent: FC<NodeProps<AssignerNodeType>> = ({
if (!variable || variable.length === 0)
return null
const isSystem = isSystemVar(variable)
const isEnv = isENV(variable)
const isChatVar = isConversationVar(variable)
const node = isSystem ? nodes.find(node => node.data.type === BlockEnum.Start) : nodes.find(node => node.id === variable[0])
const varName = isSystem ? `sys.${variable[variable.length - 1]}` : variable.slice(1).join('.')
return (
<NodeVariableItem
key={index}
node={node as Node}
isEnv={isEnv}
isChatVar={isChatVar}
variable={variable}
writeMode={value.operation}
varName={varName}
className='bg-workflow-block-parma-bg'
/>
)
@ -63,19 +58,13 @@ const NodeComponent: FC<NodeProps<AssignerNodeType>> = ({
if (!variable || variable.length === 0)
return null
const isSystem = isSystemVar(variable)
const isEnv = isENV(variable)
const isChatVar = isConversationVar(variable)
const node = isSystem ? nodes.find(node => node.data.type === BlockEnum.Start) : nodes.find(node => node.id === variable[0])
const varName = isSystem ? `sys.${variable[variable.length - 1]}` : variable.slice(1).join('.')
return (
<div className='relative flex flex-col items-start gap-0.5 self-stretch px-3 py-1'>
<NodeVariableItem
node={node as Node}
isEnv={isEnv}
isChatVar={isChatVar}
varName={varName}
variable={variable}
writeMode={writeMode}
className='bg-workflow-block-parma-bg'
/>

View File

@ -4,7 +4,7 @@ import { useNodes } from 'reactflow'
import { useTranslation } from 'react-i18next'
import NodeVariableItem from '../variable-assigner/components/node-variable-item'
import type { DocExtractorNodeType } from './types'
import { isConversationVar, isENV, isSystemVar } from '@/app/components/workflow/nodes/_base/components/variable/utils'
import { isSystemVar } from '@/app/components/workflow/nodes/_base/components/variable/utils'
import { BlockEnum, type Node, type NodeProps } from '@/app/components/workflow/types'
const i18nPrefix = 'workflow.nodes.docExtractor'
@ -21,18 +21,13 @@ const NodeComponent: FC<NodeProps<DocExtractorNodeType>> = ({
return null
const isSystem = isSystemVar(variable)
const isEnv = isENV(variable)
const isChatVar = isConversationVar(variable)
const node = isSystem ? nodes.find(node => node.data.type === BlockEnum.Start) : nodes.find(node => node.id === variable[0])
const varName = isSystem ? `sys.${variable[variable.length - 1]}` : variable.slice(1).join('.')
return (
<div className='relative px-3'>
<div className='system-2xs-medium-uppercase mb-1 text-text-tertiary'>{t(`${i18nPrefix}.inputVar`)}</div>
<NodeVariableItem
node={node as Node}
isEnv={isEnv}
isChatVar={isChatVar}
varName={varName}
variable={variable}
className='bg-workflow-block-parma-bg'
/>
</div>

View File

@ -4,7 +4,7 @@ import { useNodes } from 'reactflow'
import { useTranslation } from 'react-i18next'
import NodeVariableItem from '../variable-assigner/components/node-variable-item'
import type { ListFilterNodeType } from './types'
import { isConversationVar, isENV, isSystemVar } from '@/app/components/workflow/nodes/_base/components/variable/utils'
import { isSystemVar } from '@/app/components/workflow/nodes/_base/components/variable/utils'
import { BlockEnum, type Node, type NodeProps } from '@/app/components/workflow/types'
const i18nPrefix = 'workflow.nodes.listFilter'
@ -21,18 +21,13 @@ const NodeComponent: FC<NodeProps<ListFilterNodeType>> = ({
return null
const isSystem = isSystemVar(variable)
const isEnv = isENV(variable)
const isChatVar = isConversationVar(variable)
const node = isSystem ? nodes.find(node => node.data.type === BlockEnum.Start) : nodes.find(node => node.id === variable[0])
const varName = isSystem ? `sys.${variable[variable.length - 1]}` : variable.slice(1).join('.')
return (
<div className='relative px-3'>
<div className='system-2xs-medium-uppercase mb-1 text-text-tertiary'>{t(`${i18nPrefix}.inputVar`)}</div>
<NodeVariableItem
node={node as Node}
isEnv={isEnv}
isChatVar={isChatVar}
varName={varName}
variable={variable}
className='bg-workflow-block-parma-bg'
/>
</div>

View File

@ -19,7 +19,7 @@ import {
import { filterVar } from '../utils'
import AddVariable from './add-variable'
import NodeVariableItem from './node-variable-item'
import { isConversationVar, isENV, isSystemVar } from '@/app/components/workflow/nodes/_base/components/variable/utils'
import { isSystemVar } from '@/app/components/workflow/nodes/_base/components/variable/utils'
import cn from '@/utils/classnames'
import { isExceptionVariable } from '@/app/components/workflow/utils'
@ -124,9 +124,6 @@ const NodeGroupItem = ({
{
!!item.variables.length && item.variables.map((variable = [], index) => {
const isSystem = isSystemVar(variable)
const isEnv = isENV(variable)
const isChatVar = isConversationVar(variable)
const node = isSystem ? nodes.find(node => node.data.type === BlockEnum.Start) : nodes.find(node => node.id === variable[0])
const varName = isSystem ? `sys.${variable[variable.length - 1]}` : variable.slice(1).join('.')
const isException = isExceptionVariable(varName, node?.data.type)
@ -134,11 +131,9 @@ const NodeGroupItem = ({
return (
<NodeVariableItem
key={index}
isEnv={isEnv}
isChatVar={isChatVar}
variable={variable}
isException={isException}
node={node as Node}
varName={varName}
showBorder={showSelectedBorder || showSelectionBorder}
/>
)

View File

@ -9,13 +9,13 @@ import { Line3 } from '@/app/components/base/icons/src/public/common'
import { Variable02 } from '@/app/components/base/icons/src/vender/solid/development'
import { BubbleX, Env } from '@/app/components/base/icons/src/vender/line/others'
import Badge from '@/app/components/base/badge'
import type { Node } from '@/app/components/workflow/types'
import type { Node, ValueSelector } from '@/app/components/workflow/types'
import { isConversationVar, isENV, isRagVariableVar, isSystemVar } from '@/app/components/workflow/nodes/_base/components/variable/utils'
import { InputField } from '@/app/components/base/icons/src/vender/pipeline'
type NodeVariableItemProps = {
isEnv: boolean
isChatVar: boolean
node: Node
varName: string
variable: ValueSelector
writeMode?: string
showBorder?: boolean
className?: string
@ -25,10 +25,8 @@ type NodeVariableItemProps = {
const i18nPrefix = 'workflow.nodes.assigner'
const NodeVariableItem = ({
isEnv,
isChatVar,
node,
varName,
variable,
writeMode,
showBorder,
className,
@ -36,6 +34,12 @@ const NodeVariableItem = ({
}: NodeVariableItemProps) => {
const { t } = useTranslation()
const isSystem = isSystemVar(variable)
const isEnv = isENV(variable)
const isChatVar = isConversationVar(variable)
const isRagVar = isRagVariableVar(variable)
const varName = isSystem ? `sys.${variable[variable.length - 1]}` : variable.slice(1).join('.')
const VariableIcon = useMemo(() => {
if (isEnv) {
return (
@ -49,6 +53,12 @@ const NodeVariableItem = ({
)
}
if(isRagVar) {
return (
<InputField className='h-3.5 w-3.5 shrink-0 text-text-accent' />
)
}
return (
<Variable02
className={cn(
@ -57,7 +67,7 @@ const NodeVariableItem = ({
)}
/>
)
}, [isEnv, isChatVar, isException])
}, [isEnv, isChatVar, isRagVar, isException])
const VariableName = useMemo(() => {
return (