|
|
@@ -52,7 +52,7 @@
|
|
|
<Workflow
|
|
|
ref="workflowRef"
|
|
|
:id="workflow?.id"
|
|
|
- :workflow="workflow"
|
|
|
+ :workflow="workflowWithExecutionState"
|
|
|
:nodeMap="nodeMap"
|
|
|
@click:node="handleSelectNode"
|
|
|
@dblclick:node="handleNodeClick"
|
|
|
@@ -81,7 +81,7 @@
|
|
|
<Setter
|
|
|
:id="nodeID"
|
|
|
:workflow="workflow!"
|
|
|
- @update:node:data="hangleUpdateNodeData"
|
|
|
+ @update:node:data="handleUpdateNodeData"
|
|
|
@run-node="handleRunNode"
|
|
|
v-model:visible="setterVisible"
|
|
|
/>
|
|
|
@@ -105,7 +105,7 @@
|
|
|
</template>
|
|
|
|
|
|
<script setup lang="ts">
|
|
|
-import { ref, inject, type CSSProperties, onBeforeUnmount, watch, nextTick } from 'vue'
|
|
|
+import { computed, ref, inject, type CSSProperties, onBeforeUnmount, watch, nextTick } from 'vue'
|
|
|
import { useRoute, useRouter } from 'vue-router'
|
|
|
import { agent } from '@repo/api-service'
|
|
|
|
|
|
@@ -127,7 +127,8 @@ import type {
|
|
|
XYPosition,
|
|
|
Connection,
|
|
|
ConnectStartEvent,
|
|
|
- IWorkflowNode
|
|
|
+ IWorkflowNode,
|
|
|
+ CanvasExecutionStatus
|
|
|
} from '@repo/workflow'
|
|
|
|
|
|
const layout = inject<{ setMainStyle: (style: CSSProperties) => void }>('layout')
|
|
|
@@ -168,6 +169,45 @@ const workflow = ref<IWorkflow>(
|
|
|
edges: []
|
|
|
}
|
|
|
)
|
|
|
+
|
|
|
+const mapNodeExecutionStatus = (status?: string): CanvasExecutionStatus => {
|
|
|
+ if (status === 'running') {
|
|
|
+ return 'running'
|
|
|
+ }
|
|
|
+
|
|
|
+ if (status === 'success') {
|
|
|
+ return 'success'
|
|
|
+ }
|
|
|
+
|
|
|
+ if (status === 'failed') {
|
|
|
+ return 'warning'
|
|
|
+ }
|
|
|
+
|
|
|
+ return 'idle'
|
|
|
+}
|
|
|
+
|
|
|
+const workflowWithExecutionState = computed<IWorkflow>(() => {
|
|
|
+ const baseWorkflow = workflow.value
|
|
|
+ const runnerNodeStatusMap = new Map(
|
|
|
+ runnerStore.nodes.map((item) => [item.nodeId, mapNodeExecutionStatus(item.status)])
|
|
|
+ )
|
|
|
+
|
|
|
+ return {
|
|
|
+ ...baseWorkflow,
|
|
|
+ nodes: (baseWorkflow.nodes || []).map((node) => {
|
|
|
+ const executionStatus = runnerNodeStatusMap.get(node.id) || 'idle'
|
|
|
+
|
|
|
+ return {
|
|
|
+ ...node,
|
|
|
+ executionStatus,
|
|
|
+ data: {
|
|
|
+ ...(node.data || {}),
|
|
|
+ executionStatus
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+})
|
|
|
const inputRef = ref<InstanceType<typeof Input>>()
|
|
|
const saveAgentTimer = ref<number | undefined>(undefined)
|
|
|
const saveVarsTimer = ref<number | undefined>(undefined)
|
|
|
@@ -556,12 +596,16 @@ const handleNodeCreate = (value: { type: string; position?: XYPosition } | strin
|
|
|
// 需要连接前一个节点
|
|
|
if (peddingHandlePayload.value) {
|
|
|
const { position, handle, parentId } = peddingHandlePayload.value
|
|
|
+
|
|
|
newNodeParam.position = position
|
|
|
newNodeParam.prevNodeId = handle.nodeId
|
|
|
newNodeParam.parentId = parentId
|
|
|
if (handle.handleId?.includes('_')) {
|
|
|
newNodeParam.nodeHandleId = handle.handleId
|
|
|
}
|
|
|
+ if (handle.handleId?.endsWith('-else')) {
|
|
|
+ newNodeParam.nodeHandleId = handle.nodeId
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
if (!newNodeParam.position) {
|
|
|
@@ -613,7 +657,6 @@ const handleDelete = () => {
|
|
|
cancelButtonText: '取消',
|
|
|
type: 'warning'
|
|
|
}).then(() => {
|
|
|
- console.log('删除成功')
|
|
|
localStorage.removeItem(`project_${id}`)
|
|
|
router.push('/')
|
|
|
})
|
|
|
@@ -648,6 +691,11 @@ const onCreateConnection = async (connection: Connection) => {
|
|
|
params.sourceHandle = sourceHandle
|
|
|
}
|
|
|
|
|
|
+ // 如果是source条件节点else的sourceHandle模式就是当前节点id
|
|
|
+ if (sourceHandle && sourceHandle.endsWith('-else')) {
|
|
|
+ params.sourceHandle = source
|
|
|
+ }
|
|
|
+
|
|
|
if (!workflow.value?.edges.some((edge) => edge.source === source && edge.target === target)) {
|
|
|
const response = await agent.postAgentDoNewEdge(params)
|
|
|
|