Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
赵月辉
/
fastgpt-migrated
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Unverified
Commit
1e68a5fe
authored
Jan 04, 2026
by
heheer
Committed by
GitHub
Jan 04, 2026
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
connection handle (#6178)
parent
34241ec7
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
60 additions
and
18 deletions
+60
-18
projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/hooks/useWorkflow.tsx
+21
-4
projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/nodes/render/Handle/ConnectionHandle.tsx
+39
-14
No files found.
projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/hooks/useWorkflow.tsx
View file @
1e68a5fe
...
@@ -827,10 +827,27 @@ export const useWorkflow = () => {
...
@@ -827,10 +827,27 @@ export const useWorkflow = () => {
// Prevent native context menu from showing
// Prevent native context menu from showing
e
.
preventDefault
();
e
.
preventDefault
();
setMenu
({
// Context menu dimensions
top
:
e
.
clientY
+
6
,
const
contextMenuWidth
=
120
;
left
:
e
.
clientX
-
12
const
contextMenuHeight
=
120
;
});
const
viewportWidth
=
window
.
innerWidth
;
const
viewportHeight
=
window
.
innerHeight
;
const
margin
=
10
;
let
top
=
e
.
clientY
+
6
;
let
left
=
e
.
clientX
-
12
;
// Check right boundary
if
(
left
+
contextMenuWidth
+
margin
>
viewportWidth
)
{
left
=
Math
.
max
(
margin
,
e
.
clientX
-
contextMenuWidth
);
}
// Check bottom boundary
if
(
top
+
contextMenuHeight
+
margin
>
viewportHeight
)
{
top
=
Math
.
max
(
margin
,
viewportHeight
-
contextMenuHeight
-
margin
);
}
setMenu
({
top
,
left
});
},
},
[
setMenu
]
[
setMenu
]
);
);
...
...
projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/nodes/render/Handle/ConnectionHandle.tsx
View file @
1e68a5fe
import
React
,
{
useMemo
}
from
'react'
;
import
React
,
{
useMemo
}
from
'react'
;
import
{
Position
}
from
'reactflow'
;
import
{
Position
}
from
'reactflow'
;
import
{
MySourceHandle
,
MyTargetHandle
}
from
'.'
;
import
{
MySourceHandle
,
MyTargetHandle
}
from
'.'
;
import
{
getHandleId
}
from
'@fastgpt/global/core/workflow/utils'
;
import
{
getHandleId
,
getElseIFLabel
}
from
'@fastgpt/global/core/workflow/utils'
;
import
{
NodeOutputKeyEnum
}
from
'@fastgpt/global/core/workflow/constants'
;
import
{
Node
InputKeyEnum
,
Node
OutputKeyEnum
}
from
'@fastgpt/global/core/workflow/constants'
;
import
{
useContextSelector
}
from
'use-context-selector'
;
import
{
useContextSelector
}
from
'use-context-selector'
;
import
{
WorkflowBufferDataContext
}
from
'../../../../context/workflowInitContext'
;
import
{
WorkflowBufferDataContext
}
from
'../../../../context/workflowInitContext'
;
import
{
WorkflowActionsContext
}
from
'../../../../context/workflowActionsContext'
;
import
{
WorkflowActionsContext
}
from
'../../../../context/workflowActionsContext'
;
import
{
FlowNodeTypeEnum
}
from
'@fastgpt/global/core/workflow/node/constant'
;
export
const
ConnectionSourceHandle
=
({
export
const
ConnectionSourceHandle
=
({
nodeId
,
nodeId
,
...
@@ -28,24 +29,48 @@ export const ConnectionSourceHandle = ({
...
@@ -28,24 +29,48 @@ export const ConnectionSourceHandle = ({
})();
})();
const
RightHandle
=
(()
=>
{
const
RightHandle
=
(()
=>
{
// When the node is folded and has multiple branches, only render the first output.
if
(
node
?.
isFolded
)
{
const
firstHandleId
=
(()
=>
{
if
(
node
.
flowNodeType
===
FlowNodeTypeEnum
.
userSelect
)
{
const
options
=
node
?.
inputs
?.
find
(
(
input
)
=>
input
.
key
===
NodeInputKeyEnum
.
userSelectOptions
)?.
value
;
if
(
options
&&
options
.
length
>
0
)
{
return
getHandleId
(
nodeId
,
'source'
,
options
[
0
].
key
);
}
}
else
if
(
node
.
flowNodeType
===
FlowNodeTypeEnum
.
ifElseNode
)
{
return
getHandleId
(
nodeId
,
'source'
,
getElseIFLabel
(
0
));
}
else
if
(
node
.
flowNodeType
===
FlowNodeTypeEnum
.
classifyQuestion
)
{
const
options
=
node
?.
inputs
?.
find
(
(
input
)
=>
input
.
key
===
NodeInputKeyEnum
.
agents
)?.
value
;
if
(
options
&&
options
.
length
>
0
)
{
return
getHandleId
(
nodeId
,
'source'
,
options
[
0
].
key
);
}
}
})();
if
(
firstHandleId
)
{
return
(
<
MySourceHandle
nodeId=
{
nodeId
}
handleId=
{
firstHandleId
}
position=
{
Position
.
Right
}
translate=
{
[
4
,
0
]
}
/>
);
}
}
const
handleId
=
getHandleId
(
nodeId
,
sourceType
,
Position
.
Right
);
const
handleId
=
getHandleId
(
nodeId
,
sourceType
,
Position
.
Right
);
const
rightTargetConnected
=
edges
.
some
(
const
rightTargetConnected
=
edges
.
some
(
(
edge
)
=>
edge
.
targetHandle
===
getHandleId
(
nodeId
,
'target'
,
Position
.
Right
)
(
edge
)
=>
edge
.
targetHandle
===
getHandleId
(
nodeId
,
'target'
,
Position
.
Right
)
);
);
/*
if
(
!
node
||
!
node
?.
showSourceHandle
||
rightTargetConnected
)
{
If the node is folded and has outputs, must show the handle
hide handle when:
- not folded
- not node
- not sourceHandle
- already connected
*/
if
(
!
(
node
?.
isFolded
&&
node
?.
outputs
.
length
)
&&
(
!
node
||
!
node
?.
showSourceHandle
||
rightTargetConnected
)
)
return
null
;
return
null
;
}
return
(
return
(
<
MySourceHandle
<
MySourceHandle
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment