Feature/newnew workflow loop node (#14863)

Co-authored-by: arkunzz <4873204@qq.com>
This commit is contained in:
Wood
2025-03-05 17:41:15 +08:00
committed by GitHub
parent da91217bc9
commit 2c17bb2c36
131 changed files with 6031 additions and 159 deletions

View File

@@ -35,7 +35,7 @@ export enum ComparisonOperator {
notExists = 'not exists',
}
export interface Condition {
export type Condition = {
id: string
varType: VarType
variable_selector?: ValueSelector
@@ -46,7 +46,7 @@ export interface Condition {
sub_variable_condition?: CaseItem
}
export interface CaseItem {
export type CaseItem = {
case_id: string
logical_operator: LogicalOperator
conditions: Condition[]
@@ -57,6 +57,7 @@ export type IfElseNodeType = CommonNodeType & {
conditions?: Condition[]
cases: CaseItem[]
isInIteration: boolean
isInLoop: boolean
}
export type HandleAddCondition = (caseId: string, valueSelector: ValueSelector, varItem: Var) => void

View File

@@ -57,6 +57,7 @@ const useConfig = (id: string, payload: IfElseNodeType) => {
} = useIsVarFileAttribute({
nodeId: id,
isInIteration: payload.isInIteration,
isInLoop: payload.isInLoop,
})
const varsIsVarFileAttribute = useMemo(() => {

View File

@@ -7,10 +7,12 @@ import { VarType } from '../../types'
type Params = {
nodeId: string
isInIteration: boolean
isInLoop: boolean
}
const useIsVarFileAttribute = ({
nodeId,
isInIteration,
isInLoop,
}: Params) => {
const isChatMode = useIsChatMode()
const store = useStoreApi()
@@ -20,6 +22,7 @@ const useIsVarFileAttribute = ({
} = store.getState()
const currentNode = getNodes().find(n => n.id === nodeId)
const iterationNode = isInIteration ? getNodes().find(n => n.id === currentNode!.parentId) : null
const loopNode = isInLoop ? getNodes().find(n => n.id === currentNode!.parentId) : null
const availableNodes = useMemo(() => {
return getBeforeNodesInSameBranch(nodeId)
}, [getBeforeNodesInSameBranch, nodeId])
@@ -29,7 +32,7 @@ const useIsVarFileAttribute = ({
return false
const parentVariable = variable.slice(0, 2)
const varType = getCurrentVariableType({
parentNode: iterationNode,
parentNode: isInIteration ? iterationNode : loopNode,
valueSelector: parentVariable,
availableNodes,
isChatMode,