222
schangxiang@126.com
2025-04-30 9bec4dcae002f36aa23231da11cb03a156b40110
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
// 贝塞尔曲线
import { BezierEdge, BezierEdgeModel } from '@logicflow/core'
import { CURVE } from '../../core/enum' // 折线
import { PolylineEdge, PolylineEdgeModel } from '@logicflow/core'
import { CurvedEdge, CurvedEdgeModel } from '@logicflow/extension'
 
class CurveModel extends BezierEdgeModel {
  initEdgeData(data: any) {
    super.initEdgeData(data)
    this.radius = 500
  }
  setAttributes() {
    this.isAnimation = true
    this.text.editable = false
    this.offset = 20
    const t = setTimeout(() => {
      this.isAnimation = false
      clearTimeout(t)
    }, 3000)
  }
  getEdgeAnimationStyle() {
    const style = super.getEdgeAnimationStyle()
    style.strokeDasharray = '15 2'
    style.animationDuration = '30s'
    style.stroke = '#5a84ff'
    // #9265f3
    return style
  }
  getEdgeStyle() {
    const style = super.getEdgeStyle()
    const { properties } = this
    if (properties.isActived) {
      style.strokeDasharray = '2 2'
    }
    if (this.isSelected || this.isHovered) {
      style.stroke = '#5a84ff'
    } else {
      style.stroke = '#c4c8d5'
    }
    return style
  }
  getTextStyle() {
    const style: Record<string, any> = super.getTextStyle()
    style.color = '#444'
    style.fontSize = 13
    if (this.isSelected || this.isHovered) {
      style.color = '#5a84ff'
    } else {
      style.color = '#444'
    }
    return style
  }
 
  getOutlineStyle() {
    const style: Record<string, any> = super.getOutlineStyle()
    style.stroke = '#5a84ff'
    style.hover.stroke = '#5a84ff'
    return style
  }
  getAdjustStart() {}
}
 
export default {
  type: CURVE,
  view: BezierEdge,
  model: CurveModel,
}