|
@@ -1,7 +1,7 @@
|
|
|
<template>
|
|
<template>
|
|
|
<div class="w-full h-full flex flex-col">
|
|
<div class="w-full h-full flex flex-col">
|
|
|
<div
|
|
<div
|
|
|
- class="h-60px border-b border-b-solid border-gray-200 flex items-center justify-between px-12px"
|
|
|
|
|
|
|
+ class="h-60px shrink-0 border-b border-b-solid border-gray-200 flex items-center justify-between px-12px"
|
|
|
>
|
|
>
|
|
|
<div class="left flex items-center gap-4">
|
|
<div class="left flex items-center gap-4">
|
|
|
<el-breadcrumb separator="/">
|
|
<el-breadcrumb separator="/">
|
|
@@ -34,10 +34,16 @@
|
|
|
@drop="handleDrop"
|
|
@drop="handleDrop"
|
|
|
@run="handleRunWorkflow"
|
|
@run="handleRunWorkflow"
|
|
|
@update:nodes:position="handleUpdateNodesPosition"
|
|
@update:nodes:position="handleUpdateNodesPosition"
|
|
|
|
|
+ @update:node:attrs="handleUpdateNodeProps"
|
|
|
class="bg-#f5f5f5"
|
|
class="bg-#f5f5f5"
|
|
|
/>
|
|
/>
|
|
|
<RunWork v-model:visible="runVisible" />
|
|
<RunWork v-model:visible="runVisible" />
|
|
|
- <Setter :data="nodeID" v-model:visible="setterVisible" />
|
|
|
|
|
|
|
+ <Setter
|
|
|
|
|
+ :id="nodeID"
|
|
|
|
|
+ :workflow="workflow"
|
|
|
|
|
+ @update:node:data="hangleUpdateNodeData"
|
|
|
|
|
+ v-model:visible="setterVisible"
|
|
|
|
|
+ />
|
|
|
</el-splitter-panel>
|
|
</el-splitter-panel>
|
|
|
|
|
|
|
|
<el-splitter-panel v-model:size.lazy="footerHeight" :min="32">
|
|
<el-splitter-panel v-model:size.lazy="footerHeight" :min="32">
|
|
@@ -48,7 +54,7 @@
|
|
|
</template>
|
|
</template>
|
|
|
|
|
|
|
|
<script setup lang="ts">
|
|
<script setup lang="ts">
|
|
|
-import { ref, inject, type CSSProperties } from 'vue'
|
|
|
|
|
|
|
+import { ref, inject, type CSSProperties, onBeforeUnmount } from 'vue'
|
|
|
import { startNode, endNode, httpNode, conditionNode, databaseNode, codeNode } from '@repo/nodes'
|
|
import { startNode, endNode, httpNode, conditionNode, databaseNode, codeNode } from '@repo/nodes'
|
|
|
import { Workflow, type IWorkflow, type XYPosition, type Connection } from '@repo/workflow'
|
|
import { Workflow, type IWorkflow, type XYPosition, type Connection } from '@repo/workflow'
|
|
|
import { v4 as uuid } from 'uuid'
|
|
import { v4 as uuid } from 'uuid'
|
|
@@ -71,7 +77,7 @@ const footerHeight = ref(32)
|
|
|
|
|
|
|
|
const workflow = ref<IWorkflow>({
|
|
const workflow = ref<IWorkflow>({
|
|
|
id: uuid(),
|
|
id: uuid(),
|
|
|
- nodes: [],
|
|
|
|
|
|
|
+ nodes: [startNode, endNode],
|
|
|
edges: []
|
|
edges: []
|
|
|
})
|
|
})
|
|
|
|
|
|
|
@@ -100,14 +106,14 @@ const handleNodeCreate = (value: SourceType | string) => {
|
|
|
workflow.value.nodes.push({
|
|
workflow.value.nodes.push({
|
|
|
id: uuid(),
|
|
id: uuid(),
|
|
|
type: 'canvas-node',
|
|
type: 'canvas-node',
|
|
|
- zIndex: 0,
|
|
|
|
|
|
|
+ zIndex: -1,
|
|
|
position: { x: 600, y: 300 },
|
|
position: { x: 600, y: 300 },
|
|
|
data: {
|
|
data: {
|
|
|
version: ['1.0.0'],
|
|
version: ['1.0.0'],
|
|
|
inputs: [],
|
|
inputs: [],
|
|
|
outputs: [],
|
|
outputs: [],
|
|
|
renderType: 'stickyNote',
|
|
renderType: 'stickyNote',
|
|
|
- content: '注释内容,可以使用 **Markdown** 语法进行格式化。',
|
|
|
|
|
|
|
+ content: '注释内容,可以使用 **Markdown** 语法进行格式化, 双击进入编辑。',
|
|
|
width: 400,
|
|
width: 400,
|
|
|
height: 200,
|
|
height: 200,
|
|
|
color: '#fff5d6'
|
|
color: '#fff5d6'
|
|
@@ -176,4 +182,35 @@ const handleUpdateNodesPosition = (events: { id: string; position: XYPosition }[
|
|
|
}
|
|
}
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+/**
|
|
|
|
|
+ * 修改节点数据
|
|
|
|
|
+ */
|
|
|
|
|
+const hangleUpdateNodeData = (id: string, data: any) => {
|
|
|
|
|
+ const node = workflow.value.nodes.find((node) => node.id === id)
|
|
|
|
|
+ if (node) {
|
|
|
|
|
+ node.data = {
|
|
|
|
|
+ ...node.data,
|
|
|
|
|
+ ...data
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+/**
|
|
|
|
|
+ * 修改节点属性
|
|
|
|
|
+ */
|
|
|
|
|
+const handleUpdateNodeProps = (id: string, attrs: Record<string, unknown>) => {
|
|
|
|
|
+ const node = workflow.value.nodes.find((node) => node.id === id)
|
|
|
|
|
+ if (node) {
|
|
|
|
|
+ if (node.data?.renderType === 'stickyNote') {
|
|
|
|
|
+ Object.assign(node.data, attrs)
|
|
|
|
|
+ } else {
|
|
|
|
|
+ Object.assign(node, attrs)
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+onBeforeUnmount(() => {
|
|
|
|
|
+ layout?.setMainStyle({})
|
|
|
|
|
+})
|
|
|
</script>
|
|
</script>
|