wangyanshen
2023-01-09 695c5a332e4bf10b6b93c9973e1634730b4a60df
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
<template>
    <div style="height:100%">
        <div id="container" />
    </div>
  </template>
  <script>
  
  import FlowGraph from "@/views/main/flow-x6/graph/index";
  import { $, } from "@/utils/util";
  import graphData from "@/views/main/flow-x6/graph/data/data";
  export default {
    name:'x6_view',
    data() {
      return {
        destroyFn: null,
      };
    },
    components: {  },
    mounted() {
      this.destroyFn = this.initGraph();
    },
    destroyed() {
      // 移除监听、销毁画布、资源回收
      this.destroyFn();
    },
    methods: {
      initGraph() {
        const graph = FlowGraph.init(
          $("#container"),
          $("#container").getBoundingClientRect().width,
          $("#container").getBoundingClientRect().height,false
        );
        graph.fromJSON(graphData);
        setTimeout(() => {
            graph.zoomToFit()
        }, 500);
       
        // const resizeFn = () => {
        //   const { width, height } = getContainerSize($('.panel'))
        //   graph.resize(width, height - 38)
        // }
        // resizeFn()
        // window.addEventListener('resize', resizeFn)
        return () => {
          // window.removeEventListener('resize', resizeFn)
          graph.dispose();
        };
      },
      
    },
  };
  </script>
  <style>
  .x6-widget-snapline-vertical {
    border-right-color: #ff4e50 !important;
  }
  .x6-widget-snapline-horizontal {
    border-bottom-color: #ff4e50 !important;
  }
  .x6-widget-selection-box {
    border: 1px dashed #5f95ff;
    margin-top: -3px;
    margin-left: -3px;
  }
  .x6-widget-selection-inner {
    border: 1px dashed #5f95ff;
  }
  
  @keyframes stroke {
    100% {
      stroke-dashoffset: -400;
    }
  }
  .animate-text1,
  .animate-text2,
  .animate-text3,
  .animate-text4 {
    font-weight: bold;
    fill: none;
    stroke-width: 2px;
    stroke-dasharray: 90 310;
    animation: stroke 3s infinite linear;
  }
  .animate-text1 {
    stroke: #873bf4;
    text-shadow: 0 0 2px #873bf4;
    animation-delay: -1.5s;
  }
  .animate-text2 {
    stroke: #ff6e06;
    text-shadow: 0 0 2px #ff6e06;
    animation-delay: -3s;
  }
  .x6-graph-background{
    /* background-image: url("../../../assets/images/pump/12.gif"); */
  }
  </style>