@zhangqingcq/vgce 0.0.13 → 0.0.15

Sign up to get free protection for your applications and to get access to all the features.
Files changed (135) hide show
  1. package/README.md +16 -2
  2. package/dist/style.css +1 -1
  3. package/dist/vgce.js +28 -34
  4. package/dist/vgce.umd.cjs +5 -5
  5. package/package.json +3 -2
  6. package/src/App.vue +11 -0
  7. package/src/assets/base.less +49 -0
  8. package/src/assets/icons/add.svg +1 -0
  9. package/src/assets/icons/delete.svg +12 -0
  10. package/src/assets/icons/export.svg +1 -0
  11. package/src/assets/icons/group.svg +13 -0
  12. package/src/assets/icons/import.svg +1 -0
  13. package/src/assets/icons/lock.svg +7 -0
  14. package/src/assets/icons/menu-fold.svg +9 -0
  15. package/src/assets/icons/menu-unfold.svg +9 -0
  16. package/src/assets/icons/preview.svg +6 -0
  17. package/src/assets/icons/redo.svg +8 -0
  18. package/src/assets/icons/return.svg +8 -0
  19. package/src/assets/icons/rotate.svg +1 -0
  20. package/src/assets/icons/save.svg +9 -0
  21. package/src/assets/icons/setting.svg +6 -0
  22. package/src/assets/icons/undo.svg +7 -0
  23. package/src/assets/icons/ungroup.svg +16 -0
  24. package/src/assets/icons/unlock.svg +7 -0
  25. package/src/assets/main.less +6 -0
  26. package/src/assets/svgs/alternator.svg +8 -0
  27. package/src/assets/svgs/bot-12.svg +1 -0
  28. package/src/assets/svgs/bot-2.svg +1 -0
  29. package/src/assets/svgs/bot-3.svg +1 -0
  30. package/src/assets/svgs/bot-7.svg +1 -0
  31. package/src/assets/svgs/bot-9.svg +94 -0
  32. package/src/assets/svgs/car.svg +1 -0
  33. package/src/assets/svgs/circuit-breaker.svg +11 -0
  34. package/src/assets/svgs/clock-a.svg +23 -0
  35. package/src/assets/svgs/common-table.svg +7 -0
  36. package/src/assets/svgs/el-button.svg +10 -0
  37. package/src/assets/svgs/el-tag.svg +13 -0
  38. package/src/assets/svgs/hospital.svg +1 -0
  39. package/src/assets/svgs/house.svg +1 -0
  40. package/src/assets/svgs/light.svg +24 -0
  41. package/src/assets/svgs/now-time.svg +9 -0
  42. package/src/assets/svgs/package.svg +1 -0
  43. package/src/assets/svgs/pie-charts.svg +10 -0
  44. package/src/assets/svgs/progress-a.svg +1 -0
  45. package/src/assets/svgs/reservoir.svg +10 -0
  46. package/src/assets/svgs/svg-text.svg +5 -0
  47. package/src/assets/svgs/switch-a.svg +5 -0
  48. package/src/assets/svgs/traction-transformer.svg +11 -0
  49. package/src/components/ace-edit/index.ts +27 -0
  50. package/src/components/config/index.ts +450 -0
  51. package/src/components/config/types.ts +25 -0
  52. package/src/components/svg-analysis/index.vue +11 -0
  53. package/src/components/svg-editor/center-panel/index.vue +867 -0
  54. package/src/components/svg-editor/center-panel/types.ts +11 -0
  55. package/src/components/svg-editor/component-tree/index.vue +33 -0
  56. package/src/components/svg-editor/connection-line/index.vue +125 -0
  57. package/src/components/svg-editor/connection-panel/index.vue +198 -0
  58. package/src/components/svg-editor/export-json/index.vue +37 -0
  59. package/src/components/svg-editor/handle-panel/index.vue +342 -0
  60. package/src/components/svg-editor/import-json/index.vue +37 -0
  61. package/src/components/svg-editor/index.vue +280 -0
  62. package/src/components/svg-editor/left-panel/index.vue +83 -0
  63. package/src/components/svg-editor/right-panel/code-edit-modal.vue +50 -0
  64. package/src/components/svg-editor/right-panel/common-animate.vue +96 -0
  65. package/src/components/svg-editor/right-panel/condition.vue +101 -0
  66. package/src/components/svg-editor/right-panel/dynamic-el-form-item.vue +97 -0
  67. package/src/components/svg-editor/right-panel/index.vue +304 -0
  68. package/src/components/svg-editor/right-panel/list.vue +86 -0
  69. package/src/components/svg-editor/top-panel/index.vue +139 -0
  70. package/src/components/svg-editor/types.ts +22 -0
  71. package/src/components/svg-viewer/index.vue +340 -0
  72. package/src/components/vue3-ruler-tool/index.vue +506 -0
  73. package/src/config/files/clock-a.vue +66 -0
  74. package/src/config/files/common-table.vue +49 -0
  75. package/src/config/files/light-a.vue +72 -0
  76. package/src/config/files/now-time.vue +53 -0
  77. package/src/config/files/pie-charts.vue +72 -0
  78. package/src/config/files/progress.vue +40 -0
  79. package/src/config/files/svg-text.vue +39 -0
  80. package/src/config/files/switch-a.vue +45 -0
  81. package/src/config/index.ts +28 -0
  82. package/src/config/svg/animation/index.ts +8 -0
  83. package/src/config/svg/animation/reservoir.ts +32 -0
  84. package/src/config/svg/custom/clock-a.ts +23 -0
  85. package/src/config/svg/custom/index.ts +11 -0
  86. package/src/config/svg/custom/light.ts +29 -0
  87. package/src/config/svg/custom/svg-text.ts +54 -0
  88. package/src/config/svg/custom/switch-a.ts +29 -0
  89. package/src/config/svg/index.ts +12 -0
  90. package/src/config/svg/stateful/circuit-breaker.ts +38 -0
  91. package/src/config/svg/stateful/index.ts +8 -0
  92. package/src/config/svg/stateless/alternator.ts +28 -0
  93. package/src/config/svg/stateless/bot-12.ts +22 -0
  94. package/src/config/svg/stateless/bot-2.ts +22 -0
  95. package/src/config/svg/stateless/bot-3.ts +22 -0
  96. package/src/config/svg/stateless/bot-7.ts +22 -0
  97. package/src/config/svg/stateless/bot-9.ts +22 -0
  98. package/src/config/svg/stateless/car.ts +22 -0
  99. package/src/config/svg/stateless/hospital.ts +22 -0
  100. package/src/config/svg/stateless/house.ts +22 -0
  101. package/src/config/svg/stateless/index.ts +30 -0
  102. package/src/config/svg/stateless/package.ts +22 -0
  103. package/src/config/svg/stateless/traction-transformer.ts +28 -0
  104. package/src/config/types.ts +126 -0
  105. package/src/config/vue/component/button.ts +57 -0
  106. package/src/config/vue/component/common-table.ts +124 -0
  107. package/src/config/vue/component/index.ts +13 -0
  108. package/src/config/vue/component/now-time.ts +29 -0
  109. package/src/config/vue/component/progress.ts +29 -0
  110. package/src/config/vue/component/tag.ts +46 -0
  111. package/src/config/vue/echarts/index.ts +8 -0
  112. package/src/config/vue/echarts/pie-charts.ts +60 -0
  113. package/src/config/vue/index.ts +5 -0
  114. package/src/hooks.ts +47 -0
  115. package/src/index.ts +14 -0
  116. package/src/main.ts +15 -0
  117. package/src/router.ts +24 -0
  118. package/src/stores/config/index.ts +44 -0
  119. package/src/stores/config/types.ts +27 -0
  120. package/src/stores/global/index.ts +109 -0
  121. package/src/stores/global/types.ts +115 -0
  122. package/src/stores/main.ts +10 -0
  123. package/src/stores/svg-edit-layout/index.ts +17 -0
  124. package/src/stores/svg-edit-layout/types.ts +8 -0
  125. package/src/stores/system/index.ts +174 -0
  126. package/src/stores/system/types.ts +43 -0
  127. package/src/utils/fetch.ts +351 -0
  128. package/src/utils/file-read-write.ts +26 -0
  129. package/src/utils/index.ts +397 -0
  130. package/src/utils/mqtt-net.ts +48 -0
  131. package/src/utils/proxy.ts +7 -0
  132. package/src/utils/scale-core.ts +214 -0
  133. package/src/utils/types.ts +13 -0
  134. package/src/views/EditorS.vue +18 -0
  135. package/src/views/Preview.vue +12 -0
@@ -0,0 +1,11 @@
1
+ import type { IDoneJson } from '@/stores/global/types'
2
+
3
+ export interface IVisibleInfo {
4
+ handle_panel: boolean
5
+ connection_panel: boolean
6
+ connection_line: boolean
7
+ select_item: {
8
+ info: null | IDoneJson
9
+ index: number
10
+ }
11
+ }
@@ -0,0 +1,33 @@
1
+ <script lang="ts" setup>
2
+ import { ref } from 'vue'
3
+ import { pinia } from '@/hooks'
4
+ import { useGlobalStore } from '@/stores/global'
5
+ import { ElTree } from 'element-plus'
6
+ import { EGlobalStoreIntention } from '@/stores/global/types'
7
+ import type { IDoneJson } from '@/stores/global/types'
8
+
9
+ const global_store = useGlobalStore(pinia)
10
+ const current_node_key = ref(global_store.handle_svg_info?.info.id || '')
11
+ const handleNodeClick = (data: IDoneJson) => {
12
+ global_store.intention = EGlobalStoreIntention.Select
13
+ global_store.setHandleSvgInfo(data)
14
+ }
15
+
16
+ const defaultProps = {
17
+ children: 'children',
18
+ label: 'title'
19
+ }
20
+ </script>
21
+
22
+ <template>
23
+ <el-tree
24
+ :data="global_store.done_json"
25
+ :props="defaultProps"
26
+ @node-click="handleNodeClick"
27
+ :default-expand-all="true"
28
+ :expand-on-click-node="false"
29
+ :highlight-current="true"
30
+ node-key="id"
31
+ :current-node-key="current_node_key"
32
+ />
33
+ </template>
@@ -0,0 +1,125 @@
1
+ <script setup lang="ts">
2
+ import { EMouseInfoState, EGlobalStoreIntention } from '@/stores/global/types'
3
+ import type { IDoneJson } from '@/stores/global/types'
4
+ import { positionArrToPath } from '@/utils'
5
+ import { pinia } from '@/hooks'
6
+ import { useGlobalStore } from '@/stores/global'
7
+ import { EConfigAnimationsType } from '@/config/types'
8
+
9
+ const props = withDefaults(defineProps<{ itemInfo: IDoneJson; pointVisible: boolean }>(), { pointVisible: false })
10
+ const globalStore = useGlobalStore(pinia)
11
+ const setConnectionLineNode = (point_index: number, e: MouseEvent, x: number, y: number) => {
12
+ if (globalStore.intention === EGlobalStoreIntention.Connection) {
13
+ return
14
+ }
15
+ globalStore.setHandleSvgInfo(props.itemInfo)
16
+ const { clientX, clientY } = e
17
+ e.stopPropagation()
18
+ globalStore.connection_line_node_info = {
19
+ init_pos: {
20
+ x,
21
+ y
22
+ },
23
+ point_index: point_index
24
+ }
25
+ globalStore.intention = EGlobalStoreIntention.SetConnectionLineNode
26
+ globalStore.setMouseInfo({
27
+ state: EMouseInfoState.Down,
28
+ position_x: clientX,
29
+ position_y: clientY,
30
+ now_position_x: clientX,
31
+ now_position_y: clientY,
32
+ new_position_x: 0,
33
+ new_position_y: 0
34
+ })
35
+ }
36
+ </script>
37
+
38
+ <template>
39
+ <g>
40
+ <path
41
+ :id="props.itemInfo.id"
42
+ :d="positionArrToPath(props.itemInfo.props.point_position.val)"
43
+ fill="none"
44
+ :stroke="
45
+ props.itemInfo.animations?.type.val === EConfigAnimationsType.Electricity
46
+ ? props.itemInfo.animations.color.val
47
+ : props.itemInfo.props.stroke.val
48
+ "
49
+ :stroke-width="props.itemInfo.props['stroke-width'].val"
50
+ style="cursor: move"
51
+ stroke-dashoffset="0"
52
+ :stroke-dasharray="
53
+ props.itemInfo.animations?.type.val === EConfigAnimationsType.Electricity
54
+ ? props.itemInfo.props['stroke-width'].val * 3
55
+ : 0
56
+ "
57
+ >
58
+ <animate
59
+ v-if="props.itemInfo.animations?.type.val === EConfigAnimationsType.Electricity"
60
+ attributeName="stroke-dashoffset"
61
+ :from="props.itemInfo.animations.reverse.val ? 0 : 1000"
62
+ :to="props.itemInfo.animations.reverse.val ? 1000 : 0"
63
+ :dur="`${props.itemInfo.animations.dur.val}s`"
64
+ :repeatCount="props.itemInfo.animations.repeatCount.val"
65
+ />
66
+ </path>
67
+ <!-- 水珠 -->
68
+ <path
69
+ v-if="props.itemInfo.animations?.type.val === EConfigAnimationsType.WaterDrop"
70
+ :d="positionArrToPath(props.itemInfo.props.point_position.val)"
71
+ fill="none"
72
+ fill-opacity="0"
73
+ :stroke="props.itemInfo.animations.color.val"
74
+ :stroke-width="props.itemInfo.props['stroke-width'].val"
75
+ :stroke-dasharray="props.itemInfo.props['stroke-width'].val * 3"
76
+ stroke-dashoffset="0"
77
+ stroke-linecap="round"
78
+ >
79
+ <animate
80
+ attributeName="stroke-dashoffset"
81
+ :from="props.itemInfo.animations.reverse.val ? 0 : 1000"
82
+ :to="props.itemInfo.animations.reverse.val ? 1000 : 0"
83
+ :dur="`${props.itemInfo.animations.dur.val}s`"
84
+ :repeatCount="props.itemInfo.animations.repeatCount.val"
85
+ fill="freeze"
86
+ />
87
+ </path>
88
+ <!-- 轨迹 -->
89
+ <circle
90
+ v-else-if="props.itemInfo.animations?.type.val === EConfigAnimationsType.Track"
91
+ cx="0"
92
+ cy="0"
93
+ :r="props.itemInfo.props['stroke-width'].val * 2"
94
+ :fill="props.itemInfo.animations.color.val"
95
+ >
96
+ <animateMotion
97
+ :path="
98
+ positionArrToPath(
99
+ props.itemInfo.animations.reverse.val
100
+ ? [...props.itemInfo.props.point_position.val].reverse()
101
+ : props.itemInfo.props.point_position.val
102
+ )
103
+ "
104
+ :dur="`${props.itemInfo.animations.dur.val}s`"
105
+ :repeatCount="props.itemInfo.animations.repeatCount.val"
106
+ >
107
+ </animateMotion>
108
+ </circle>
109
+ <!-- 更改线段 -->
110
+ <g v-if="props.pointVisible">
111
+ <circle
112
+ v-for="(item, index) in props.itemInfo.props.point_position.val"
113
+ :key="index"
114
+ :cx="item.x"
115
+ :cy="item.y"
116
+ r="6"
117
+ stroke-width="1"
118
+ :stroke="props.itemInfo.props.stroke.val"
119
+ fill="#fff"
120
+ style="cursor: pointer"
121
+ @mousedown="setConnectionLineNode(index, $event, item.x, item.y)"
122
+ />
123
+ </g>
124
+ </g>
125
+ </template>
@@ -0,0 +1,198 @@
1
+ <!-- 连线组件 -->
2
+ <script lang="ts" setup>
3
+ import { straight_line_system } from '@/components/config'
4
+ import { ELineBindAnchors } from '@/components/config/types'
5
+ import type { ISystemStraightLine } from '@/components/config/types'
6
+ import { pinia } from '@/hooks'
7
+ import { useConfigStore } from '@/stores/config'
8
+ import { ref } from 'vue'
9
+ import { useGlobalStore } from '@/stores/global'
10
+ import { EGlobalStoreIntention, EMouseInfoState } from '@/stores/global/types'
11
+ import type { IDoneJson } from '@/stores/global/types'
12
+ import { getAnchorPosByAnchorType, getCoordinateOffset, objectDeepClone, randomString } from '@/utils'
13
+
14
+ const props = defineProps<{ itemInfo: IDoneJson }>()
15
+ const globalStore = useGlobalStore(pinia)
16
+ const configStore = useConfigStore(pinia)
17
+ const offset = ref(4)
18
+ const fill = ref('#4F80FF')
19
+ const radius = ref(4)
20
+ /**
21
+ * 点了连线
22
+ * @param bind_anchor_type 绑定锚点类型
23
+ * @param e
24
+ */
25
+ const onConnectionMouseDown = (bind_anchor_type: ELineBindAnchors, e: MouseEvent) => {
26
+ e.preventDefault()
27
+
28
+ const { clientX, clientY } = e
29
+ let create_line_info = objectDeepClone<ISystemStraightLine>(configStore.connection_line)
30
+ console.log('onConnectionMouseDown', configStore.connection_line, e)
31
+ //以后顶部可以选择连线是哪种 直线先不做
32
+ /*if (false) {
33
+ create_line_info = straight_line_system
34
+ }*/
35
+ create_line_info.bind_anchors.start = {
36
+ type: bind_anchor_type,
37
+ target_id: props.itemInfo.id
38
+ }
39
+ const { x, y } = getAnchorPosByAnchorType(bind_anchor_type, props.itemInfo)
40
+ const done_item_json = {
41
+ id: straight_line_system.name + randomString(),
42
+ x: x,
43
+ y: y,
44
+ client: {
45
+ x: clientX,
46
+ y: clientY
47
+ },
48
+ scale_x: 1,
49
+ scale_y: 1,
50
+ rotate: 0,
51
+ actual_bound: {
52
+ x: 0,
53
+ y: 0,
54
+ width: 0,
55
+ height: 0
56
+ },
57
+ point_coordinate: {
58
+ tl: {
59
+ x: 0,
60
+ y: 0
61
+ },
62
+ tc: {
63
+ x: 0,
64
+ y: 0
65
+ },
66
+ tr: {
67
+ x: 0,
68
+ y: 0
69
+ },
70
+ l: {
71
+ x: 0,
72
+ y: 0
73
+ },
74
+ r: {
75
+ x: 0,
76
+ y: 0
77
+ },
78
+ bl: {
79
+ x: 0,
80
+ y: 0
81
+ },
82
+ bc: {
83
+ x: 0,
84
+ y: 0
85
+ },
86
+ br: {
87
+ x: 0,
88
+ y: 0
89
+ }
90
+ },
91
+ ...create_line_info
92
+ }
93
+ done_item_json.props.point_position.val.push({
94
+ x: configStore.svg.svg_position_center.x,
95
+ y: configStore.svg.svg_position_center.y
96
+ })
97
+ globalStore.setHandleSvgInfo(done_item_json, globalStore.done_json.length)
98
+ globalStore.setDoneJson(done_item_json)
99
+
100
+ globalStore.intention = EGlobalStoreIntention.Connection
101
+ globalStore.setMouseInfo({
102
+ state: EMouseInfoState.Down,
103
+ position_x: clientX,
104
+ position_y: clientY,
105
+ now_position_x: clientX,
106
+ now_position_y: clientY,
107
+ new_position_x: 0,
108
+ new_position_y: 0
109
+ })
110
+ }
111
+ </script>
112
+
113
+ <template>
114
+ <g style="vector-effect: non-scaling-stroke">
115
+ <circle
116
+ id="connection_tc"
117
+ :cx="props.itemInfo.actual_bound.x + props.itemInfo.actual_bound.width / 2 - offset + radius"
118
+ :cy="
119
+ props.itemInfo.actual_bound.y -
120
+ offset -
121
+ getCoordinateOffset(props.itemInfo.actual_bound.height, props.itemInfo.scale_y) +
122
+ radius
123
+ "
124
+ :r="radius"
125
+ stroke="rgba(0,0,0,0)"
126
+ stroke-width="2"
127
+ :fill="fill"
128
+ :style="{ 'vector-effect': 'non-scaling-stroke', cursor: 'pointer' }"
129
+ pointer-events="all"
130
+ @mousedown="onConnectionMouseDown(ELineBindAnchors.TopCenter, $event)"
131
+ />
132
+ <circle
133
+ id="connection_l"
134
+ :cx="
135
+ props.itemInfo.actual_bound.x -
136
+ offset -
137
+ getCoordinateOffset(props.itemInfo.actual_bound.width, props.itemInfo.scale_x) +
138
+ radius
139
+ "
140
+ :cy="
141
+ props.itemInfo.actual_bound.y -
142
+ offset +
143
+ (props.itemInfo.actual_bound.height * props.itemInfo.scale_y) / 2 -
144
+ getCoordinateOffset(props.itemInfo.actual_bound.height, props.itemInfo.scale_y) +
145
+ radius
146
+ "
147
+ :r="radius"
148
+ stroke="rgba(0,0,0,0)"
149
+ stroke-width="2"
150
+ :fill="fill"
151
+ :style="{ 'vector-effect': 'non-scaling-stroke', cursor: 'pointer' }"
152
+ pointer-events="all"
153
+ @mousedown="onConnectionMouseDown(ELineBindAnchors.Left, $event)"
154
+ />
155
+ <circle
156
+ id="connection_r"
157
+ :cx="
158
+ props.itemInfo.actual_bound.x -
159
+ offset +
160
+ props.itemInfo.actual_bound.width +
161
+ getCoordinateOffset(props.itemInfo.actual_bound.width, props.itemInfo.scale_x) +
162
+ radius
163
+ "
164
+ :cy="
165
+ props.itemInfo.actual_bound.y -
166
+ offset +
167
+ (props.itemInfo.actual_bound.height * props.itemInfo.scale_y) / 2 -
168
+ getCoordinateOffset(props.itemInfo.actual_bound.height, props.itemInfo.scale_y) +
169
+ radius
170
+ "
171
+ :r="radius"
172
+ stroke="rgba(0,0,0,0)"
173
+ stroke-width="2"
174
+ :fill="fill"
175
+ :style="{ 'vector-effect': 'non-scaling-stroke', cursor: 'pointer' }"
176
+ pointer-events="all"
177
+ @mousedown="onConnectionMouseDown(ELineBindAnchors.Right, $event)"
178
+ />
179
+ <circle
180
+ id="connection_bc"
181
+ :cx="props.itemInfo.actual_bound.x - offset + props.itemInfo.actual_bound.width / 2 + radius"
182
+ :cy="
183
+ props.itemInfo.actual_bound.y -
184
+ offset +
185
+ props.itemInfo.actual_bound.height +
186
+ getCoordinateOffset(props.itemInfo.actual_bound.height, props.itemInfo.scale_y) +
187
+ radius
188
+ "
189
+ :r="radius"
190
+ stroke="rgba(0,0,0,0)"
191
+ stroke-width="2"
192
+ :fill="fill"
193
+ :style="{ 'vector-effect': 'non-scaling-stroke', cursor: 'pointer' }"
194
+ pointer-events="all"
195
+ @mousedown="onConnectionMouseDown(ELineBindAnchors.BottomCenter, $event)"
196
+ />
197
+ </g>
198
+ </template>
@@ -0,0 +1,37 @@
1
+ <script setup lang="ts">
2
+ import { onMounted, ref } from 'vue'
3
+ import { VAceEditor } from 'vue3-ace-editor'
4
+ import '@/components/ace-edit'
5
+ import { pinia } from '@/hooks'
6
+ import { useGlobalStore } from '@/stores/global'
7
+ import { useSvgEditLayoutStore } from '@/stores/svg-edit-layout'
8
+ import { useConfigStore } from '@/stores/config'
9
+ import type { IDataModel } from '@/components/svg-editor/types'
10
+ const content = ref('')
11
+ const globalStore = useGlobalStore(pinia)
12
+ const svgEditLayoutStore = useSvgEditLayoutStore(pinia)
13
+ const configStore = useConfigStore(pinia)
14
+ onMounted(() => {
15
+ const export_json: IDataModel = {
16
+ layout_center: svgEditLayoutStore.center_offset,
17
+ config: configStore.$state,
18
+ done_json: globalStore.done_json
19
+ }
20
+ content.value = JSON.stringify(export_json, null, 2)
21
+ })
22
+ </script>
23
+
24
+ <template>
25
+ <v-ace-editor
26
+ v-model:value="content"
27
+ lang="json"
28
+ theme="kr_theme"
29
+ style="height: 400px"
30
+ :options="{
31
+ useWorker: true,
32
+ enableBasicAutocompletion: true,
33
+ enableSnippets: true,
34
+ enableLiveAutocompletion: true
35
+ }"
36
+ />
37
+ </template>