feat(web): 完成循环节点的基本配置
This commit is contained in:
@@ -28,6 +28,7 @@ export const sourceNodeNotFoundError = () => new CheckError(200, '连线起始
|
||||
export const targetNodeNotFoundError = () => new CheckError(201, '连线目标节点未找到')
|
||||
export const nodeToSelfError = () => new CheckError(203, '节点不能直连自身')
|
||||
export const hasCycleError = () => new CheckError(204, '禁止流程循环')
|
||||
export const differentParent = () => new CheckError(205, '子流程禁止连接外部节点')
|
||||
|
||||
const hasCycle = (sourceNode: Node, targetNode: Node, nodes: Node[], edges: Edge[], visited = new Set<string>()) => {
|
||||
if (visited.has(targetNode.id)) return false
|
||||
@@ -48,6 +49,10 @@ export const checkAddConnection: (connection: Connection, nodes: Node[], edges:
|
||||
throw targetNodeNotFoundError()
|
||||
}
|
||||
|
||||
if (!isEqual(sourceNode.parentId, targetNode.parentId)) {
|
||||
throw differentParent()
|
||||
}
|
||||
|
||||
// 禁止流程出现环,必须是有向无环图
|
||||
if (isEqual(sourceNode.id, targetNode.id)) {
|
||||
throw nodeToSelfError()
|
||||
|
||||
Reference in New Issue
Block a user