From 3d64382c9b525565f070c61ad6e63b16ece1b21e Mon Sep 17 00:00:00 2001 From: jxxghp Date: Wed, 26 Feb 2025 21:11:24 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=9B=B4=E6=96=B0=E6=8B=96=E6=94=BE?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=EF=BC=8C=E9=87=8D=E6=9E=84=E7=8A=B6=E6=80=81?= =?UTF-8?q?=E7=AE=A1=E7=90=86=EF=BC=8C=E4=BC=98=E5=8C=96=E5=B7=A5=E4=BD=9C?= =?UTF-8?q?=E6=B5=81=E7=BB=84=E4=BB=B6=EF=BC=8C=E6=B7=BB=E5=8A=A0=E8=8A=82?= =?UTF-8?q?=E7=82=B9=E5=92=8C=E8=BE=B9=E7=9A=84=E7=A1=AE=E8=AE=A4=E5=88=A0?= =?UTF-8?q?=E9=99=A4=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/@core/utils/workflow.ts | 24 +-- src/api/types.ts | 32 +--- .../dialog/WorkflowActionsDialog.vue | 170 ++++++++++++++++-- .../workflow/DropzoneBackground.vue | 1 - src/components/workflow/Sidebar.vue | 67 ++++++- src/views/workflow/WorkflowListView.vue | 10 -- 6 files changed, 234 insertions(+), 70 deletions(-) diff --git a/src/@core/utils/workflow.ts b/src/@core/utils/workflow.ts index 6db5ef50..01b73e3d 100644 --- a/src/@core/utils/workflow.ts +++ b/src/@core/utils/workflow.ts @@ -7,24 +7,24 @@ let id = 0 * @returns {string} - A unique id. */ function getId() { - return `dndnode_${id++}` + return `act_${id++}` } /** * In a real world scenario you'd want to avoid creating refs in a global scope like this as they might not be cleaned up properly. - * @type {{draggedType: Ref, isDragOver: Ref, isDragging: Ref}} + * @type {{draggedData: Ref, isDragOver: Ref, isDragging: Ref}} */ const state = { /** * The type of the node being dragged. */ - draggedType: ref(null), + draggedData: ref(null), isDragOver: ref(false), isDragging: ref(false), } export default function useDragAndDrop() { - const { draggedType, isDragOver, isDragging } = state + const { draggedData, isDragOver, isDragging } = state const { addNodes, screenToFlowCoordinate, onNodesInitialized, updateNode } = useVueFlow() @@ -32,13 +32,13 @@ export default function useDragAndDrop() { document.body.style.userSelect = dragging ? 'none' : '' }) - function onDragStart(event: any, type: any) { + function onDragStart(event: any, data: any) { if (event.dataTransfer) { - event.dataTransfer.setData('application/vueflow', type) + event.dataTransfer.setData('application/vueflow', data) event.dataTransfer.effectAllowed = 'move' } - draggedType.value = type + draggedData.value = data isDragging.value = true document.addEventListener('drop', onDragEnd) @@ -52,7 +52,7 @@ export default function useDragAndDrop() { function onDragOver(event: any) { event.preventDefault() - if (draggedType.value) { + if (draggedData.value) { isDragOver.value = true if (event.dataTransfer) { @@ -68,7 +68,7 @@ export default function useDragAndDrop() { function onDragEnd() { isDragging.value = false isDragOver.value = false - draggedType.value = null + draggedData.value = null document.removeEventListener('drop', onDragEnd) } @@ -87,9 +87,9 @@ export default function useDragAndDrop() { const newNode = { id: nodeId, - type: draggedType.value || undefined, + type: undefined, position, - data: { label: nodeId }, + data: draggedData.value, } /** @@ -109,7 +109,7 @@ export default function useDragAndDrop() { } return { - draggedType, + draggedData, isDragOver, isDragging, onDragStart, diff --git a/src/api/types.ts b/src/api/types.ts index 0c2bed73..8dd8e57c 100644 --- a/src/api/types.ts +++ b/src/api/types.ts @@ -1262,34 +1262,6 @@ export interface SiteCategory { desc: string } -// 动作 -export interface Action { - // 动作ID (类名) - id?: string - // 动作名称 - name?: string - // 动作描述 - description?: string - // 是否需要循环 - loop?: boolean - // 循环间隔 (秒) - loop_interval?: number - // 参数 - params?: { [key: string]: any } -} - -// 工作流 -export interface ActionFlow { - // ID - id?: string - // 源动作 - source?: string - // 目标动作 - target?: string - // 是否动画流程 - animated?: boolean -} - // 工作流 export interface Workflow { // 工作流ID @@ -1309,9 +1281,9 @@ export interface Workflow { // 已执行次数 run_count?: number // 动作列表 - actions?: Action[] + actions?: any[] // 动作流 - flows?: ActionFlow[] + flows?: any[] // 创建时间 add_time?: string // 最后执行时间 diff --git a/src/components/dialog/WorkflowActionsDialog.vue b/src/components/dialog/WorkflowActionsDialog.vue index 65c8f8e7..19a0a4b4 100644 --- a/src/components/dialog/WorkflowActionsDialog.vue +++ b/src/components/dialog/WorkflowActionsDialog.vue @@ -1,19 +1,59 @@