|
@@ -59,13 +59,14 @@
|
|
|
width="360px"
|
|
width="360px"
|
|
|
virtual-triggering
|
|
virtual-triggering
|
|
|
>
|
|
>
|
|
|
- <NodeLibary
|
|
|
|
|
- @add-node="handleNodeCreate"
|
|
|
|
|
- @mouseleave="onHideNodeLibary"
|
|
|
|
|
- :parent-node-type="nodeLibaryParentType"
|
|
|
|
|
- hide-start
|
|
|
|
|
- ignore-drag
|
|
|
|
|
- />
|
|
|
|
|
|
|
+ <div ref="nodeLibraryPanelRef">
|
|
|
|
|
+ <NodeLibary
|
|
|
|
|
+ @add-node="handleNodeCreate"
|
|
|
|
|
+ :parent-node-type="nodeLibaryParentType"
|
|
|
|
|
+ hide-start
|
|
|
|
|
+ ignore-drag
|
|
|
|
|
+ />
|
|
|
|
|
+ </div>
|
|
|
</el-popover>
|
|
</el-popover>
|
|
|
</template>
|
|
</template>
|
|
|
|
|
|
|
@@ -127,6 +128,7 @@ const workflowRef = ref<InstanceType<typeof Workflow>>()
|
|
|
const showNodeLibary = ref(false)
|
|
const showNodeLibary = ref(false)
|
|
|
const libaryRefferenceRef = ref<HTMLElement>()
|
|
const libaryRefferenceRef = ref<HTMLElement>()
|
|
|
const nodeLibaryPopoverAnchorRef = ref<HTMLElement>()
|
|
const nodeLibaryPopoverAnchorRef = ref<HTMLElement>()
|
|
|
|
|
+const nodeLibraryPanelRef = ref<HTMLElement>()
|
|
|
const runVisible = ref(false)
|
|
const runVisible = ref(false)
|
|
|
const closeRunWorkflowOnSubmit = ref(false)
|
|
const closeRunWorkflowOnSubmit = ref(false)
|
|
|
const runWorkflowInputOnly = ref(false)
|
|
const runWorkflowInputOnly = ref(false)
|
|
@@ -617,7 +619,8 @@ const handleNodeCreate = (value: { type: string; position?: XYPosition } | strin
|
|
|
newNodeParam.position = position
|
|
newNodeParam.position = position
|
|
|
newNodeParam.prevNodeId = handle?.nodeId
|
|
newNodeParam.prevNodeId = handle?.nodeId
|
|
|
newNodeParam.parentId = parentId
|
|
newNodeParam.parentId = parentId
|
|
|
- if (handle?.handleId?.includes('_')) {
|
|
|
|
|
|
|
+ // 包含下划线或者没中划线的
|
|
|
|
|
+ if (handle?.handleId?.includes('_') || !handle?.handleId?.includes('-')) {
|
|
|
newNodeParam.nodeHandleId = handle?.handleId
|
|
newNodeParam.nodeHandleId = handle?.handleId
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -745,8 +748,8 @@ const onCreateConnection = async (connection: Connection) => {
|
|
|
target,
|
|
target,
|
|
|
zIndex: 1
|
|
zIndex: 1
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- if (sourceHandle && sourceHandle.includes('_')) {
|
|
|
|
|
|
|
+ // 只有当 sourceHandle 包含下划线或者不包含中划线时才传给后端,其他情况后端会自动匹配。
|
|
|
|
|
+ if (sourceHandle && sourceHandle.includes('_') && !sourceHandle.includes('-')) {
|
|
|
params.sourceHandle = sourceHandle
|
|
params.sourceHandle = sourceHandle
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -863,6 +866,7 @@ const handleUpdateNode = (node: IWorkflowNode) => {
|
|
|
agent
|
|
agent
|
|
|
.postAgentDoUpdateAgentNode(buildUpdateNodePayload(syncedNode))
|
|
.postAgentDoUpdateAgentNode(buildUpdateNodePayload(syncedNode))
|
|
|
.then((response) => {
|
|
.then((response) => {
|
|
|
|
|
+ // todo: 更新完成后会返回节点数据,同步本地节点数据
|
|
|
handleApiResult(response, undefined, t('pages.nodeView.messages.updateNodeFailed'))
|
|
handleApiResult(response, undefined, t('pages.nodeView.messages.updateNodeFailed'))
|
|
|
})
|
|
})
|
|
|
.catch((error) => {
|
|
.catch((error) => {
|
|
@@ -977,6 +981,40 @@ const onHideNodeLibary = () => {
|
|
|
}, 500)
|
|
}, 500)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+const onGlobalPointerDown = (event: PointerEvent) => {
|
|
|
|
|
+ if (!showNodeLibary.value) {
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ const target = event.target as Node | null
|
|
|
|
|
+ if (!target) {
|
|
|
|
|
+ onHideNodeLibary()
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ const panelEl = nodeLibraryPanelRef.value
|
|
|
|
|
+ if (panelEl?.contains(target)) {
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ const anchorEl = libaryRefferenceRef.value
|
|
|
|
|
+ if (anchorEl?.contains(target)) {
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ onHideNodeLibary()
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+const onGlobalKeyDown = (event: KeyboardEvent) => {
|
|
|
|
|
+ if (!showNodeLibary.value) {
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (event.key === 'Escape') {
|
|
|
|
|
+ onHideNodeLibary()
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
// 根据边上加号按钮的位置打开节点库弹层。
|
|
// 根据边上加号按钮的位置打开节点库弹层。
|
|
|
const handleClickConectionAdd = (connection: Connection & { id: string }, parentId?: string) => {
|
|
const handleClickConectionAdd = (connection: Connection & { id: string }, parentId?: string) => {
|
|
|
const el = document.querySelector(`[edge-add-btn="${connection.id}"]`) as HTMLElement
|
|
const el = document.querySelector(`[edge-add-btn="${connection.id}"]`) as HTMLElement
|
|
@@ -1020,5 +1058,22 @@ const handleViewportChange = useDebounceFn((viewport: { x: number; y: number; zo
|
|
|
onBeforeUnmount(() => {
|
|
onBeforeUnmount(() => {
|
|
|
removeNodeLibaryPopoverAnchor()
|
|
removeNodeLibaryPopoverAnchor()
|
|
|
resetDisplayedNodeStatuses()
|
|
resetDisplayedNodeStatuses()
|
|
|
|
|
+ document.removeEventListener('pointerdown', onGlobalPointerDown, true)
|
|
|
|
|
+ document.removeEventListener('keydown', onGlobalKeyDown)
|
|
|
})
|
|
})
|
|
|
|
|
+
|
|
|
|
|
+watch(
|
|
|
|
|
+ showNodeLibary,
|
|
|
|
|
+ (visible) => {
|
|
|
|
|
+ if (visible) {
|
|
|
|
|
+ document.addEventListener('pointerdown', onGlobalPointerDown, true)
|
|
|
|
|
+ document.addEventListener('keydown', onGlobalKeyDown)
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ document.removeEventListener('pointerdown', onGlobalPointerDown, true)
|
|
|
|
|
+ document.removeEventListener('keydown', onGlobalKeyDown)
|
|
|
|
|
+ },
|
|
|
|
|
+ { immediate: true }
|
|
|
|
|
+)
|
|
|
</script>
|
|
</script>
|