|  | @@ -1,206 +1,85 @@
 | 
	
		
			
				|  |  | -<template>
 | 
	
		
			
				|  |  | -<div>
 | 
	
		
			
				|  |  | -  <VueFlow :nodes="nodes" :edges="edges">
 | 
	
		
			
				|  |  | -    <!-- <Panel position="top-left"> -->
 | 
	
		
			
				|  |  | -    <template #node-default="props">
 | 
	
		
			
				|  |  | -      <Handle type="source" :position="Position.Right" />
 | 
	
		
			
				|  |  | -      <div class="custom-node icons"  >
 | 
	
		
			
				|  |  | -    <img :src="props.data.image" alt="节点图片" />
 | 
	
		
			
				|  |  | -    <span>{{props.data.label }}</span>
 | 
	
		
			
				|  |  | -  </div>
 | 
	
		
			
				|  |  | -  
 | 
	
		
			
				|  |  | -  <!-- <Handle id="source-a" type="source" :position="Position.Right" style="top: 10px" />
 | 
	
		
			
				|  |  | -<Handle id="source-b" type="source" :position="Position.Right" style="bottom: 10px; top: auto;" /> -->
 | 
	
		
			
				|  |  | -  <!-- <Handle type="source" :position="Position.Left" />
 | 
	
		
			
				|  |  | -  <Handle type="target" :position="Position.Top" />
 | 
	
		
			
				|  |  | -  <Handle type="target" :position="Position.Bottom" /> -->
 | 
	
		
			
				|  |  | -    </template>
 | 
	
		
			
				|  |  | -  <Background  :gap="5" :size="0.5" :patternColor="'#C60707 '" />
 | 
	
		
			
				|  |  | -  <Controls />
 | 
	
		
			
				|  |  | -  <!-- </Panel> -->
 | 
	
		
			
				|  |  | -</VueFlow>
 | 
	
		
			
				|  |  | -</div>
 | 
	
		
			
				|  |  | -</template>
 | 
	
		
			
				|  |  |  <script setup>
 | 
	
		
			
				|  |  | -import { ref, onMounted } from 'vue'
 | 
	
		
			
				|  |  | -import { VueFlow,Handle, Position } from '@vue-flow/core'
 | 
	
		
			
				|  |  | +import { h, ref } from 'vue'
 | 
	
		
			
				|  |  | +import { VueFlow, useVueFlow } from '@vue-flow/core'
 | 
	
		
			
				|  |  |  import { Background } from '@vue-flow/background'
 | 
	
		
			
				|  |  | -import { MiniMap } from '@vue-flow/minimap'
 | 
	
		
			
				|  |  | -import { ControlButton, Controls } from '@vue-flow/controls'
 | 
	
		
			
				|  |  | -import f11 from '@/assets/img/f11.png'
 | 
	
		
			
				|  |  | -import f32 from '@/assets/img/f32.png'
 | 
	
		
			
				|  |  | -import f33 from '@/assets/img/f33.png'
 | 
	
		
			
				|  |  | -import f12 from '@/assets/img/f12.png'
 | 
	
		
			
				|  |  | -import f21 from '@/assets/img/f21.png'
 | 
	
		
			
				|  |  | -import f22 from '@/assets/img/f22.png'
 | 
	
		
			
				|  |  | -const isSource = true;
 | 
	
		
			
				|  |  | -const connectionPosition = Position.Top;
 | 
	
		
			
				|  |  | - 
 | 
	
		
			
				|  |  | -const handleSource = {
 | 
	
		
			
				|  |  | -  type: 'source',
 | 
	
		
			
				|  |  | -  position: connectionPosition,
 | 
	
		
			
				|  |  | -  // 其他可选配置...
 | 
	
		
			
				|  |  | -};
 | 
	
		
			
				|  |  | - 
 | 
	
		
			
				|  |  | -const handleTarget = {
 | 
	
		
			
				|  |  | -  type: 'target',
 | 
	
		
			
				|  |  | -  position: Position.Bottom, // 目标句柄在底部
 | 
	
		
			
				|  |  | -  // 其他可选配置...
 | 
	
		
			
				|  |  | -};
 | 
	
		
			
				|  |  | +import { useDialog } from './delete'
 | 
	
		
			
				|  |  | +import Dialog from './d.vue'
 | 
	
		
			
				|  |  | +import "./main.css";//重置样式
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +const { onConnect, addEdges, onNodesChange, onEdgesChange, applyNodeChanges, applyEdgeChanges } = useVueFlow()
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +const dialog = useDialog()
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |  const nodes = ref([
 | 
	
		
			
				|  |  | -  {
 | 
	
		
			
				|  |  | -data:{label: '开始', image: '/src/assets/img/f11.png'},
 | 
	
		
			
				|  |  | -id: "node_0",
 | 
	
		
			
				|  |  | -position: {x:245, y: 317},
 | 
	
		
			
				|  |  | -type: "default",
 | 
	
		
			
				|  |  | -handles: [
 | 
	
		
			
				|  |  | -            {
 | 
	
		
			
				|  |  | -              id: 'handle1',
 | 
	
		
			
				|  |  | -              type: 'default',
 | 
	
		
			
				|  |  | -              position: 'right',
 | 
	
		
			
				|  |  | -            },
 | 
	
		
			
				|  |  | -          ],
 | 
	
		
			
				|  |  | -},
 | 
	
		
			
				|  |  | -{
 | 
	
		
			
				|  |  | -data:{label: '优化器', image: '/src/assets/img/f32.png'},
 | 
	
		
			
				|  |  | -id: "node_1",
 | 
	
		
			
				|  |  | -position: {x: 435, y: 317},
 | 
	
		
			
				|  |  | -type: "default",
 | 
	
		
			
				|  |  | -handles: [
 | 
	
		
			
				|  |  | -            {
 | 
	
		
			
				|  |  | -              id: 'handle2',
 | 
	
		
			
				|  |  | -              type: 'default',
 | 
	
		
			
				|  |  | -              position: 'left',
 | 
	
		
			
				|  |  | -            },
 | 
	
		
			
				|  |  | -          ],
 | 
	
		
			
				|  |  | -},
 | 
	
		
			
				|  |  | -{
 | 
	
		
			
				|  |  | -data:{label: 'Rosenbank', image: '/src/assets/img/f33.png'},
 | 
	
		
			
				|  |  | -id: "node_2",
 | 
	
		
			
				|  |  | -position: {x: 630, y: 317},
 | 
	
		
			
				|  |  | -// type: "default",
 | 
	
		
			
				|  |  | -},
 | 
	
		
			
				|  |  | -{
 | 
	
		
			
				|  |  | -data:{label: '结束', image: '/src/assets/img/f12.png'},
 | 
	
		
			
				|  |  | -id: "node_3",
 | 
	
		
			
				|  |  | -position: {x: 804, y: 317},
 | 
	
		
			
				|  |  | -type: "default",
 | 
	
		
			
				|  |  | -},
 | 
	
		
			
				|  |  | -{
 | 
	
		
			
				|  |  | -data:{label: '输入1', image: '/src/assets/img/f21.png'},
 | 
	
		
			
				|  |  | -id: "node_4",
 | 
	
		
			
				|  |  | -position: {x: 521, y: 146},
 | 
	
		
			
				|  |  | -type: "default",
 | 
	
		
			
				|  |  | -draggable: true, 
 | 
	
		
			
				|  |  | -handle: [
 | 
	
		
			
				|  |  | -            {
 | 
	
		
			
				|  |  | -              id: 'handle_4',
 | 
	
		
			
				|  |  | -              position: 'Bottom',
 | 
	
		
			
				|  |  | -            },
 | 
	
		
			
				|  |  | -          ],
 | 
	
		
			
				|  |  | -},
 | 
	
		
			
				|  |  | -{
 | 
	
		
			
				|  |  | -data:{label: '输入2', image: '/src/assets/img/f21.png'},
 | 
	
		
			
				|  |  | -id: "node_5",
 | 
	
		
			
				|  |  | -position: {x:712, y: 146},
 | 
	
		
			
				|  |  | -type: "default",
 | 
	
		
			
				|  |  | -sourceHandle: 'Bottom'
 | 
	
		
			
				|  |  | -},
 | 
	
		
			
				|  |  | -{
 | 
	
		
			
				|  |  | -data:{label: '输出', image: '/src/assets/img/f22.png'},
 | 
	
		
			
				|  |  | -id: "node_6",
 | 
	
		
			
				|  |  | -position: {x: 641, y: 519},
 | 
	
		
			
				|  |  | -type: "default",
 | 
	
		
			
				|  |  | -sourceHandle: 'Top'
 | 
	
		
			
				|  |  | -},
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -]);
 | 
	
		
			
				|  |  | -let connections=ref([
 | 
	
		
			
				|  |  | -        {
 | 
	
		
			
				|  |  | -          source: 'handle1', // 源句柄ID
 | 
	
		
			
				|  |  | -          target: 'handle2', // 目标句柄ID
 | 
	
		
			
				|  |  | -        },
 | 
	
		
			
				|  |  | -      ])
 | 
	
		
			
				|  |  | -const edges = ref([
 | 
	
		
			
				|  |  | -{
 | 
	
		
			
				|  |  | -  id: 'e1->2',
 | 
	
		
			
				|  |  | -  source: 'node_0',
 | 
	
		
			
				|  |  | -  target: 'node_1',
 | 
	
		
			
				|  |  | -  type: 'straight',
 | 
	
		
			
				|  |  | -},
 | 
	
		
			
				|  |  | -{
 | 
	
		
			
				|  |  | -  id: 'e2->3',
 | 
	
		
			
				|  |  | -  source: 'node_1',
 | 
	
		
			
				|  |  | -  target: 'node_2',
 | 
	
		
			
				|  |  | -  type: 'straight'
 | 
	
		
			
				|  |  | -},
 | 
	
		
			
				|  |  | -{
 | 
	
		
			
				|  |  | -  id: 'e3->4',
 | 
	
		
			
				|  |  | -  source: 'node_2',
 | 
	
		
			
				|  |  | -  target: 'node_3',
 | 
	
		
			
				|  |  | -  type: 'straight' 
 | 
	
		
			
				|  |  | -},
 | 
	
		
			
				|  |  | -{
 | 
	
		
			
				|  |  | -  id: 'e4->5',
 | 
	
		
			
				|  |  | -  source: 'node_2',
 | 
	
		
			
				|  |  | -  target: 'node_4',
 | 
	
		
			
				|  |  | -  type: 'straight' 
 | 
	
		
			
				|  |  | -},
 | 
	
		
			
				|  |  | -{
 | 
	
		
			
				|  |  | -  id: 'e5->6',
 | 
	
		
			
				|  |  | -  source: 'node_2',
 | 
	
		
			
				|  |  | -  target: 'node_5',
 | 
	
		
			
				|  |  | -  type: 'straight' 
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -},
 | 
	
		
			
				|  |  | -{
 | 
	
		
			
				|  |  | -  id: 'e6->7',
 | 
	
		
			
				|  |  | -  source: 'node_2',
 | 
	
		
			
				|  |  | -  target: 'node_6',
 | 
	
		
			
				|  |  | -  type: 'straight' 
 | 
	
		
			
				|  |  | -},
 | 
	
		
			
				|  |  | -]);
 | 
	
		
			
				|  |  | -</script>
 | 
	
		
			
				|  |  | -<style>
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -</style>
 | 
	
		
			
				|  |  | -<style lang="scss" scoped>
 | 
	
		
			
				|  |  | -//  @import '@vue-flow/minimap/dist/style.css';
 | 
	
		
			
				|  |  | -@import '@vue-flow/minimap/dist/style.css';
 | 
	
		
			
				|  |  | -@import './main.css';
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -.vue-flow{
 | 
	
		
			
				|  |  | -width: 100%;
 | 
	
		
			
				|  |  | -  height: 100vh;
 | 
	
		
			
				|  |  | -  margin: 0 auto;
 | 
	
		
			
				|  |  | -  border: 1px solid;
 | 
	
		
			
				|  |  | -  overflow: auto;
 | 
	
		
			
				|  |  | -}
 | 
	
		
			
				|  |  | -.vue-flow__node-custom {
 | 
	
		
			
				|  |  | -  background: purple;
 | 
	
		
			
				|  |  | -  color: white;
 | 
	
		
			
				|  |  | -  border: 1px solid purple;
 | 
	
		
			
				|  |  | -  border-radius: 4px;
 | 
	
		
			
				|  |  | -  box-shadow: 0 0 0 1px purple;
 | 
	
		
			
				|  |  | -  padding: 8px;
 | 
	
		
			
				|  |  | -}
 | 
	
		
			
				|  |  | +  { id: '1', type: 'input', data: { label: 'Click me and' }, position: { x: 0, y: 0 } },
 | 
	
		
			
				|  |  | +  { id: '2', data: { label: `press 'Backspace' to delete me` }, position: { x: 0, y: 100 } },
 | 
	
		
			
				|  |  | +])
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -.icons img{
 | 
	
		
			
				|  |  | -  width: 30px;    
 | 
	
		
			
				|  |  | +const edges = ref([{ id: 'e1-2', source: '1', target: '2' }])
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +function dialogMsg(id) {
 | 
	
		
			
				|  |  | +  console.log("id"+11111111)
 | 
	
		
			
				|  |  | +  return h(
 | 
	
		
			
				|  |  | +    'span',
 | 
	
		
			
				|  |  | +    {
 | 
	
		
			
				|  |  | +      style: {
 | 
	
		
			
				|  |  | +        display: 'flex',
 | 
	
		
			
				|  |  | +        flexDirection: 'column',
 | 
	
		
			
				|  |  | +        alignItems: 'center',
 | 
	
		
			
				|  |  | +        gap: '8px',
 | 
	
		
			
				|  |  | +      },
 | 
	
		
			
				|  |  | +    },
 | 
	
		
			
				|  |  | +    [`Are you sure?`, h('br'), h('span', `[ELEMENT_ID: ${id}]`)],
 | 
	
		
			
				|  |  | +  )
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  | -.icons span{
 | 
	
		
			
				|  |  | -  display: block;
 | 
	
		
			
				|  |  | -  font-size: 13px;
 | 
	
		
			
				|  |  | -}
 | 
	
		
			
				|  |  | -</style>
 | 
	
		
			
				|  |  | -<style>
 | 
	
		
			
				|  |  | -.vue-flow__node.draggable {
 | 
	
		
			
				|  |  | -  width: 64px !important;
 | 
	
		
			
				|  |  | -    height: 64px !important;
 | 
	
		
			
				|  |  | -}
 | 
	
		
			
				|  |  | -.vue-flow__node {
 | 
	
		
			
				|  |  | -          stroke: none; /* 移除节点边框 */
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -</style>
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +onConnect(addEdges)
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +onNodesChange(async (changes) => {
 | 
	
		
			
				|  |  | +  console.log(changes)
 | 
	
		
			
				|  |  | +  const nextChanges = []
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +  for (const change of changes) {
 | 
	
		
			
				|  |  | +    if (change.type === 'remove') {
 | 
	
		
			
				|  |  | +      const isConfirmed = await dialog.confirm(dialogMsg(change.id))
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +      if (isConfirmed) {
 | 
	
		
			
				|  |  | +        nextChanges.push(change)
 | 
	
		
			
				|  |  | +      }
 | 
	
		
			
				|  |  | +    } else {
 | 
	
		
			
				|  |  | +      nextChanges.push(change)
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +  }
 | 
	
		
			
				|  |  | +  console.log(nextChanges)
 | 
	
		
			
				|  |  | +  applyNodeChanges(nextChanges)
 | 
	
		
			
				|  |  | +})
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +onEdgesChange(async (changes) => {
 | 
	
		
			
				|  |  | +  console.log(1112222)
 | 
	
		
			
				|  |  | +  const nextChanges = []
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +  for (const change of changes) {
 | 
	
		
			
				|  |  | +    if (change.type === 'remove') {
 | 
	
		
			
				|  |  | +      const isConfirmed = await dialog.confirm(dialogMsg(change.id))
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +      if (isConfirmed) {
 | 
	
		
			
				|  |  | +        nextChanges.push(change)
 | 
	
		
			
				|  |  | +      }
 | 
	
		
			
				|  |  | +    } else {
 | 
	
		
			
				|  |  | +      nextChanges.push(change)
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +  }
 | 
	
		
			
				|  |  | +  console.log(nextChanges);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +  applyEdgeChanges(nextChanges)
 | 
	
		
			
				|  |  | +})
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +</script>
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +<template>
 | 
	
		
			
				|  |  | +  <VueFlow :nodes="nodes" :edges="edges"    @node-click="onNodeClick"  @contextmenu="onContextMenu"  :apply-default="false" fit-view-on-init class="confirm-flow">
 | 
	
		
			
				|  |  | +    <Background />
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    <Dialog />
 | 
	
		
			
				|  |  | +  </VueFlow>
 | 
	
		
			
				|  |  | +</template>
 |