mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-31 09:05:30 +08:00
### What problem does this PR solve? feat: Build the edges of Switch by form data #1739 ### Type of change - [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
@ -23,7 +23,7 @@ import { devtools } from 'zustand/middleware';
|
||||
import { immer } from 'zustand/middleware/immer';
|
||||
import { Operator } from './constant';
|
||||
import { NodeData } from './interface';
|
||||
import { isEdgeEqual } from './utils';
|
||||
import { getOperatorIndex, isEdgeEqual } from './utils';
|
||||
|
||||
export type RFState = {
|
||||
nodes: Node<NodeData>[];
|
||||
@ -184,14 +184,19 @@ const useGraphStore = create<RFState>()(
|
||||
'to',
|
||||
]);
|
||||
break;
|
||||
// case Operator.Switch:
|
||||
// if (sourceHandle)
|
||||
// updateNodeForm(source, target, [
|
||||
// 'conditions',
|
||||
// sourceHandle,
|
||||
// 'to',
|
||||
// ]);
|
||||
// break;
|
||||
case Operator.Switch: {
|
||||
if (sourceHandle) {
|
||||
const operatorIndex = getOperatorIndex(sourceHandle);
|
||||
if (operatorIndex) {
|
||||
updateNodeForm(source, target, [
|
||||
'conditions',
|
||||
operatorIndex,
|
||||
'to',
|
||||
]);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -201,7 +206,11 @@ const useGraphStore = create<RFState>()(
|
||||
// Delete the edge on the classification node or relevant node anchor when the anchor is connected to other nodes
|
||||
const { edges, getOperatorTypeFromId, deleteEdgeById } = get();
|
||||
// the node containing the anchor
|
||||
const anchoredNodes = [Operator.Categorize, Operator.Relevant];
|
||||
const anchoredNodes = [
|
||||
Operator.Categorize,
|
||||
Operator.Relevant,
|
||||
Operator.Switch,
|
||||
];
|
||||
if (
|
||||
anchoredNodes.some(
|
||||
(x) => x === getOperatorTypeFromId(connection.source),
|
||||
@ -265,6 +274,19 @@ const useGraphStore = create<RFState>()(
|
||||
'to',
|
||||
]);
|
||||
break;
|
||||
case Operator.Switch: {
|
||||
if (sourceHandle) {
|
||||
const operatorIndex = getOperatorIndex(sourceHandle);
|
||||
if (operatorIndex) {
|
||||
updateNodeForm(source, undefined, [
|
||||
'conditions',
|
||||
operatorIndex,
|
||||
'to',
|
||||
]);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user