@zhangqingcq/vgce 0.0.31 → 0.0.33

Sign up to get free protection for your applications and to get access to all the features.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zhangqingcq/vgce",
3
- "version": "0.0.31",
3
+ "version": "0.0.33",
4
4
  "description": "Vector graphics configure editor. svg组态编辑器。基于vue3.3+ts+element-plus+vite",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -1,3 +1,5 @@
1
+ @import '@/assets/variables';
2
+
1
3
  *,
2
4
  *::before,
3
5
  *::after {
@@ -44,15 +46,15 @@ body {
44
46
  }
45
47
 
46
48
  .icon-out {
47
- fill: #64A0CF;
49
+ fill: @iconOutColor;
48
50
  }
49
51
 
50
52
  .icon-in {
51
- fill: #9EEFD9;
53
+ fill: @iconInColor;
52
54
  }
53
55
 
54
56
  .icon-middle {
55
- fill: #33DEB4;
57
+ fill: @iconMiddleColor;
56
58
  }
57
59
 
58
60
  .gray{
@@ -71,15 +73,15 @@ body {
71
73
 
72
74
  .active{
73
75
  .icon-out {
74
- fill: #008fff;
76
+ fill: @activeIconOut;
75
77
  }
76
78
 
77
79
  .icon-in {
78
- fill: #44fac9;
80
+ fill: @activeIconIn;
79
81
  }
80
82
 
81
83
  .icon-middle {
82
- fill: #00ffc0;
84
+ fill: @activeIconMiddle;
83
85
  }
84
86
  }
85
87
 
@@ -95,3 +97,18 @@ body {
95
97
  color: #aaa;
96
98
  }
97
99
  }
100
+
101
+ .foreignObject {
102
+ > span {
103
+ /*解决span标签显示不完整的问题*/
104
+ position: relative;
105
+ bottom: 2px;
106
+ }
107
+ }
108
+
109
+ .tree-v {
110
+ --el-color-primary-light-9: @listActiveColor;
111
+ &.el-tree--highlight-current .el-tree-node.is-current>.el-tree-node__content{
112
+ color: #fff;
113
+ }
114
+ }
@@ -1,23 +1,23 @@
1
1
  <svg viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" width="100" height="100">
2
- <path d="M512.3 518.9m-469.2 0a469.2 469.2 0 1 0 938.4 0 469.2 469.2 0 1 0-938.4 0Z" fill="#429BCF"/>
2
+ <path d="M512.3 518.9m-469.2 0a469.2 469.2 0 1 0 938.4 0 469.2 469.2 0 1 0-938.4 0Z" fill="#B3A7FF"/>
3
3
  <path d="M512.3 518.9m-392.5 0a392.5 392.5 0 1 0 785 0 392.5 392.5 0 1 0-785 0Z" fill="#FFFFFF"/>
4
- <path d="M512.3 523.8c-4.5 0-9-1.7-12.4-5.1-6.8-6.8-6.8-17.9 0-24.8l130.8-130.8c6.8-6.8 17.9-6.8 24.8 0 6.8 6.8 6.8 17.9 0 24.8L524.7 518.7c-3.5 3.4-7.9 5.1-12.4 5.1z"
5
- fill="#2D416C">
6
- <animateTransform attributeName="transform" attributeType="XML" type="rotate" from="-45 512 512"
7
- to="315 512 512" dur="43200s" repeatCount="indefinite"/>
8
- </path>
9
4
  <path d="M512.3 523.8c-4.5 0-9-1.7-12.4-5.1L318.3 337.1c-6.8-6.8-6.8-17.9 0-24.8 6.8-6.8 17.9-6.8 24.8 0L524.7 494c6.8 6.8 6.8 17.9 0 24.8-3.5 3.3-7.9 5-12.4 5z"
10
- fill="#365087">
5
+ fill="#50E68E">
11
6
  <animateTransform attributeName="transform" attributeType="XML" type="rotate" from="45 512 512"
12
7
  to="405 512 512" dur="3600s" repeatCount="indefinite"/>
13
8
  </path>
14
- <path d="M512.3 506.3m-47.5 0a47.5 47.5 0 1 0 95 0 47.5 47.5 0 1 0-95 0Z" fill="#365087"/>
9
+ <path d="M512.3 523.8c-4.5 0-9-1.7-12.4-5.1-6.8-6.8-6.8-17.9 0-24.8l130.8-130.8c6.8-6.8 17.9-6.8 24.8 0 6.8 6.8 6.8 17.9 0 24.8L524.7 518.7c-3.5 3.4-7.9 5.1-12.4 5.1z"
10
+ fill="#9A36E7">
11
+ <animateTransform attributeName="transform" attributeType="XML" type="rotate" from="-45 512 512"
12
+ to="315 512 512" dur="43200s" repeatCount="indefinite"/>
13
+ </path>
14
+ <path d="M512.3 506.3m-47.5 0a47.5 47.5 0 1 0 95 0 47.5 47.5 0 1 0-95 0Z" fill="#F45AFC"/>
15
15
  <path d="M512.3 218.8c-9 0-16.3-7.3-16.3-16.3v-29.1c0-9 7.3-16.3 16.3-16.3s16.3 7.3 16.3 16.3v29.1c0 9-7.4 16.3-16.3 16.3zM512.3 880.8c-9 0-16.3-7.3-16.3-16.3v-29.1c0-9 7.3-16.3 16.3-16.3s16.3 7.3 16.3 16.3v29.1c0 9-7.4 16.3-16.3 16.3zM812.4 518.9c0-9 7.3-16.3 16.3-16.3h29.1c9 0 16.3 7.3 16.3 16.3s-7.3 16.3-16.3 16.3h-29.1c-8.9 0-16.3-7.3-16.3-16.3zM150.4 518.9c0-9 7.3-16.3 16.3-16.3h29.1c9 0 16.3 7.3 16.3 16.3s-7.3 16.3-16.3 16.3h-29.1c-8.9 0-16.3-7.3-16.3-16.3z"
16
- fill="#2D416C"/>
16
+ fill="#4942CF"/>
17
17
  <path d="M296.9 733.5c-2.2 0-4.5-0.9-6.2-2.6-3.4-3.4-3.4-9 0-12.4L540 469.2c3.4-3.4 9-3.4 12.4 0 3.4 3.4 3.4 9 0 12.4L303.1 731c-1.7 1.7-4 2.5-6.2 2.5z"
18
- fill="#C11B16">
18
+ fill="#E83E24">
19
19
  <animateTransform attributeName="transform" attributeType="XML" type="rotate" from="135 512 512"
20
20
  to="495 512 512" dur="60s" repeatCount="indefinite"/>
21
21
  </path>
22
- <path d="M512.3 506.3m-22.8 0a22.8 22.8 0 1 0 45.6 0 22.8 22.8 0 1 0-45.6 0Z" fill="#FFFFFF"/>
22
+ <path d="M512.3 506.3m-22.8 0a22.8 22.8 0 1 0 45.6 0 22.8 22.8 0 1 0-45.6 0Z" fill="#EBF257"/>
23
23
  </svg>
@@ -0,0 +1,8 @@
1
+ //颜色
2
+ @listActiveColor: #6ab4ff;
3
+ @iconOutColor:#5fadff;
4
+ @iconInColor:#9EEFD9;
5
+ @iconMiddleColor:#33DEB4;
6
+ @activeIconOut:#008fff;
7
+ @activeIconIn:#44fac9;
8
+ @activeIconMiddle:#00ffc0;
@@ -6,6 +6,7 @@
6
6
  import { EGlobalStoreIntention, EMouseInfoState, EScaleInfoType } from '@/stores/global/types'
7
7
  import { useSvgEditLayoutStore } from '@/stores/svg-edit-layout'
8
8
  import {
9
+ componentsRegister,
9
10
  createLine,
10
11
  getCenterPoint,
11
12
  getCommonClass,
@@ -35,24 +36,17 @@
35
36
  import { EDoneJsonType } from '@/config/types'
36
37
  import ConnectionLine from '@/components/svg-editor/connection-line.vue'
37
38
  import type { IVisibleInfo } from '../config'
38
- import { vueComp } from '@/config'
39
39
  import { useContextMenuStore, useEditPrivateStore } from '@/stores/system'
40
40
  import { EContextMenuInfoType } from '@/stores/system/types'
41
- import { computed } from 'vue'
41
+ import ImportJson from '@/components/svg-editor/import-json.vue'
42
42
 
43
- //注册所有组件
44
- const instance = getCurrentInstance()
45
- Object.keys(vueComp).forEach((key) => {
46
- if (!Object.keys(instance?.appContext?.components as any).includes(key)) {
47
- // @ts-ignore
48
- instance?.appContext.app.component(key, vueComp[key])
49
- }
50
- })
51
43
  const globalStore = useGlobalStore(pinia)
52
44
  const configStore = useConfigStore(pinia)
53
45
  const svgEditLayoutStore = useSvgEditLayoutStore(pinia)
54
46
  const editPrivateStore = useEditPrivateStore(pinia)
55
47
  const contextMenuStore = useContextMenuStore(pinia)
48
+
49
+ componentsRegister()
56
50
  const contextMenuRef = ref<HTMLElement>()
57
51
  const canvasRef = ref<HTMLElement>()
58
52
  const ct: Record<string, any> = {
@@ -210,17 +204,19 @@
210
204
  const onSvgMouseDown = (select_item: IDoneJson, index: number, e: MouseEvent) => {
211
205
  canvasRef.value?.focus()
212
206
  if (globalStore.intention === EGlobalStoreIntention.Connection) {
207
+ e.stopPropagation()
213
208
  return
214
209
  }
215
210
  e.preventDefault()
216
211
  e.stopPropagation()
217
212
  if (e.ctrlKey && e.button === 0) {
218
213
  //ctrl+鼠标左键 多选组件
219
- if (globalStore.handle_svg_info?.index) {
214
+ if (globalStore.handle_svg_info?.index || globalStore.handle_svg_info?.index === 0) {
220
215
  globalStore.done_json[globalStore.handle_svg_info.index].selected = true
221
216
  globalStore.setHandleSvgInfo(null)
222
- select_item.selected = !select_item.selected
217
+ globalStore.intention = EGlobalStoreIntention.None
223
218
  }
219
+ select_item.selected = !select_item.selected
224
220
  } else if (isGroup.value) {
225
221
  //有框选的组件
226
222
  globalStore.intention = EGlobalStoreIntention.GroupMove
@@ -941,6 +937,8 @@
941
937
  }
942
938
  })
943
939
  })
940
+
941
+ defineExpose({ onCanvasMouseUp })
944
942
  </script>
945
943
 
946
944
  <template>
@@ -1087,7 +1085,11 @@
1087
1085
  />
1088
1086
 
1089
1087
  <handle-panel
1090
- v-if="globalStore.handle_svg_info?.info.id === item.id && visible_info.handle_panel"
1088
+ v-if="
1089
+ globalStore.handle_svg_info?.info.id === item.id &&
1090
+ visible_info.handle_panel &&
1091
+ item.type !== EDoneJsonType.ConnectionLine
1092
+ "
1091
1093
  :item-info="item"
1092
1094
  />
1093
1095
  <connection-panel
@@ -1136,6 +1138,8 @@
1136
1138
  </template>
1137
1139
 
1138
1140
  <style lang="less" scoped>
1141
+ @import '@/assets/variables';
1142
+
1139
1143
  .canvas {
1140
1144
  width: 100%;
1141
1145
  height: 100%;
@@ -1168,14 +1172,6 @@
1168
1172
  outline: 1px solid rgb(222, 69, 23);
1169
1173
  }
1170
1174
 
1171
- .foreignObject {
1172
- > span {
1173
- /*解决span标签显示不完整的问题*/
1174
- position: relative;
1175
- bottom: 2px;
1176
- }
1177
- }
1178
-
1179
1175
  .contextMenu {
1180
1176
  position: fixed;
1181
1177
  z-index: 99999;
@@ -1208,7 +1204,7 @@
1208
1204
  }
1209
1205
 
1210
1206
  p:hover {
1211
- background-color: #0cf;
1207
+ background-color: @listActiveColor;
1212
1208
  color: #ffffff;
1213
1209
  cursor: default;
1214
1210
  }
@@ -1220,6 +1216,7 @@
1220
1216
  .disabled:hover {
1221
1217
  color: #999;
1222
1218
  background-color: transparent;
1219
+ cursor: not-allowed;
1223
1220
  }
1224
1221
 
1225
1222
  li.separator {
@@ -6,7 +6,7 @@
6
6
  import type { IDoneJson } from '@/stores/global/types'
7
7
 
8
8
  const global_store = useGlobalStore(pinia)
9
- const current_node_key = ref(global_store.handle_svg_info?.info.id || '')
9
+ const current_node_key = computed(() => global_store.handle_svg_info?.info.id ?? '')
10
10
  const handleNodeClick = (data: IDoneJson) => {
11
11
  for (let e of global_store.done_json) {
12
12
  e.selected = false
@@ -24,12 +24,13 @@
24
24
 
25
25
  <template>
26
26
  <el-tree
27
+ class="tree-v"
27
28
  :data="global_store.done_json"
28
29
  :props="defaultProps"
29
30
  @node-click="handleNodeClick"
30
31
  :default-expand-all="true"
31
32
  :expand-on-click-node="false"
32
- :highlight-current="true"
33
+ :highlight-current="Boolean(current_node_key)"
33
34
  node-key="id"
34
35
  :current-node-key="current_node_key"
35
36
  />
@@ -40,7 +40,29 @@
40
40
  </script>
41
41
 
42
42
  <template>
43
- <g>
43
+ <g :style="{ cursor: globalStore.intention === EGlobalStoreIntention.Connection ? 'crosshair' : 'move' }">
44
+ <!-- 选中效果 -->
45
+ <path
46
+ :d="positionArrToPath(props.itemInfo.props.point_position.val)"
47
+ fill="none"
48
+ fill-opacity="0"
49
+ stroke="#DE4517"
50
+ :stroke-width="props.itemInfo.props['stroke-width'].val + 1"
51
+ stroke-linecap="round"
52
+ stroke-linejoin="round"
53
+ v-show="props.itemInfo.selected || props.itemInfo.id === globalStore.handle_svg_info?.info.id"
54
+ />
55
+ <!-- 打底 -->
56
+ <path
57
+ :d="positionArrToPath(props.itemInfo.props.point_position.val)"
58
+ fill="none"
59
+ fill-opacity="0"
60
+ stroke="#fff"
61
+ stroke-opacity=".01"
62
+ :stroke-width="props.itemInfo.props['stroke-width'].val"
63
+ stroke-linecap="round"
64
+ stroke-linejoin="round"
65
+ />
44
66
  <path
45
67
  :id="props.itemInfo.id"
46
68
  :d="positionArrToPath(props.itemInfo.props.point_position.val)"
@@ -51,13 +73,13 @@
51
73
  : props.itemInfo.props.stroke.val
52
74
  "
53
75
  :stroke-width="props.itemInfo.props['stroke-width'].val"
54
- :style="{ cursor: globalStore.intention === EGlobalStoreIntention.Connection ? 'crosshair' : 'move' }"
55
76
  stroke-dashoffset="0"
56
77
  :stroke-dasharray="
57
78
  props.itemInfo.animations?.type.val === EConfigAnimationsType.Electricity
58
79
  ? props.itemInfo.props['stroke-width'].val * 3
59
80
  : 0
60
81
  "
82
+ stroke-linejoin="round"
61
83
  >
62
84
  <animate
63
85
  v-if="props.itemInfo.animations?.type.val === EConfigAnimationsType.Electricity"
@@ -79,6 +101,7 @@
79
101
  :stroke-dasharray="props.itemInfo.props['stroke-width'].val * 3"
80
102
  stroke-dashoffset="0"
81
103
  stroke-linecap="round"
104
+ stroke-linejoin="round"
82
105
  >
83
106
  <animate
84
107
  attributeName="stroke-dashoffset"
@@ -94,7 +117,7 @@
94
117
  v-else-if="props.itemInfo.animations?.type.val === EConfigAnimationsType.Track"
95
118
  cx="0"
96
119
  cy="0"
97
- :r="props.itemInfo.props['stroke-width'].val * 2"
120
+ :r="Math.ceil(props.itemInfo.props['stroke-width'].val * 0.6) + 2"
98
121
  :fill="props.itemInfo.animations.color.val"
99
122
  >
100
123
  <animateMotion
@@ -110,8 +133,21 @@
110
133
  >
111
134
  </animateMotion>
112
135
  </circle>
113
- <!-- 更改线段 -->
114
136
  <g>
137
+ <!-- 节点选中效果 -->
138
+ <circle
139
+ v-for="(item, index) in props.itemInfo.props.point_position.val"
140
+ :key="index"
141
+ :cx="item.x"
142
+ :cy="item.y"
143
+ :r="props.itemInfo.props.point_r.val + 1"
144
+ fill="none"
145
+ fill-opacity="0"
146
+ stroke-width="1"
147
+ stroke="#DE4517"
148
+ v-show="props.itemInfo.selected || props.itemInfo.id === globalStore.handle_svg_info?.info.id"
149
+ />
150
+ <!-- 更改线段 -->
115
151
  <circle
116
152
  v-for="(item, index) in props.itemInfo.props.point_position.val"
117
153
  :key="index"
@@ -6,6 +6,7 @@
6
6
  import { createLine, getCoordinateOffset, moveAnchors } from '@/utils'
7
7
  import { useGlobalStore } from '@/stores/global'
8
8
  import { pinia } from '@/hooks'
9
+ import { useSvgEditLayoutStore } from '@/stores/svg-edit-layout'
9
10
 
10
11
  const props = defineProps<{
11
12
  itemInfo: IDoneJson
@@ -15,6 +16,7 @@
15
16
  const radius = ref(4)
16
17
  const outRadius = ref(12)
17
18
  const globalStore = useGlobalStore(pinia)
19
+ const svgEditLayoutStore = useSvgEditLayoutStore(pinia)
18
20
 
19
21
  const cxT = computed(
20
22
  () => props.itemInfo.actual_bound.x + props.itemInfo.actual_bound.width / 2 - offset.value + radius.value
@@ -105,6 +107,28 @@
105
107
  const bindAnchor = (e: any, type: ELineBindAnchors) => {
106
108
  if (globalStore.intention === EGlobalStoreIntention.None) {
107
109
  createLine(e, type, props.itemInfo)
110
+ if (globalStore.handle_svg_info) {
111
+ //鼠标左键创建新线段
112
+ if (globalStore.handle_svg_info.info.props.point_position.val.length !== 1) {
113
+ //鼠标移动后的实时位置(相对于起始点,只在创建第一个点时记录了鼠标原始位置)
114
+ globalStore.handle_svg_info.info.props.point_position.val.push({
115
+ x:
116
+ globalStore.mouse_info.new_position_x -
117
+ globalStore.mouse_info.position_x -
118
+ svgEditLayoutStore.center_offset.x,
119
+ y:
120
+ globalStore.mouse_info.new_position_y -
121
+ globalStore.mouse_info.position_y -
122
+ svgEditLayoutStore.center_offset.y
123
+ })
124
+ } else {
125
+ //第二个点,在鼠标没有移动的情况下,就是起始点
126
+ globalStore.handle_svg_info.info.props.point_position.val.push({
127
+ x: 0,
128
+ y: 0
129
+ })
130
+ }
131
+ }
108
132
  } else if (globalStore.intention === EGlobalStoreIntention.Connection) {
109
133
  //在连线的情况下,点击锚点,结束连线并绑定锚点
110
134
  e.stopPropagation()
@@ -32,8 +32,12 @@
32
32
  import { useConfigStore } from '@/stores/config'
33
33
  import { fileRead, fileWrite } from '@/utils/file-read-write'
34
34
  import { useEditPrivateStore } from '@/stores/system'
35
+ import { setEditorLoadTime } from '@/utils'
36
+
37
+ setEditorLoadTime()
35
38
 
36
39
  //todo 优化自带组件使用体验
40
+ const emits = defineEmits(['onReturn', 'onPreview', 'onSave'])
37
41
  const props = withDefaults(defineProps<{ customToolbar?: IConfig; data?: string; saveFile?: boolean }>(), {
38
42
  saveFile: false
39
43
  })
@@ -41,13 +45,13 @@
41
45
  const svgEditLayoutStore = useSvgEditLayoutStore(pinia)
42
46
  const configStore = useConfigStore(pinia)
43
47
  const editPrivateStore = useEditPrivateStore(pinia)
48
+ const centerRef = ref()
44
49
  const importJsonRef = ref<InstanceType<typeof ImportJson>>()
45
50
  const visible_conf: IVisibleConf = reactive({
46
51
  [EVisibleConfKey.ExportJson]: false,
47
52
  [EVisibleConfKey.ImportJson]: false,
48
53
  [EVisibleConfKey.ImportFile]: false
49
54
  })
50
- const emits = defineEmits(['onReturn', 'onPreview', 'onSave'])
51
55
  const changeVisible = (key: EVisibleConfKey, val: boolean) => {
52
56
  visible_conf[key] = val
53
57
  }
@@ -116,6 +120,10 @@
116
120
  }
117
121
  }
118
122
 
123
+ function onLineMouseUp() {
124
+ centerRef.value.onCanvasMouseUp()
125
+ }
126
+
119
127
  defineExpose({
120
128
  setGraphNodeJson
121
129
  })
@@ -143,8 +151,8 @@
143
151
  </el-aside>
144
152
  <el-main class="middle main">
145
153
  <div class="canvas-main-pc">
146
- <Vue3RulerTool class="canvas-main-pc" :visible="configStore.svg.ruler">
147
- <center-panel />
154
+ <Vue3RulerTool class="canvas-main-pc" :visible="configStore.svg.ruler" @onLineMouseUp="onLineMouseUp">
155
+ <center-panel ref="centerRef" />
148
156
  </Vue3RulerTool>
149
157
  </div>
150
158
  </el-main>
@@ -156,13 +156,15 @@
156
156
  <el-dialog v-model="open" title="使用说明" width="60%" class="guide-dialog">
157
157
  <el-scrollbar max-height="60vh">
158
158
  <div class="font-bold mb-10px text-15px guide-title" style="padding-top: 16px">多选</div>
159
- <div>鼠标按住左键可以框选,也可以按住ctrl+鼠标左键点图形进行多选</div>
159
+ <div
160
+ >在画布空白区域按住鼠标左键可以框选(图形坐标在框选区域即判定被选中),也可以按住ctrl+鼠标左键点图形进行多选</div
161
+ >
160
162
  <div class="el-divider el-divider--horizontal" role="separator" style="--el-border-style: solid"></div>
161
163
  <div class="font-bold mb-10px text-15px guide-title">拖动画布</div>
162
- <div>右键画布然后拖动即可,右侧面板‘图纸’栏可微调或重置位置</div>
164
+ <div>在画布空白区域按住右键可拖动画布,右侧面板‘图纸’栏可微调或重置位置</div>
163
165
  <div class="el-divider el-divider--horizontal" role="separator" style="--el-border-style: solid"></div>
164
166
  <div class="font-bold mb-10px text-15px guide-title">画布缩放</div>
165
- <div>使用鼠标滚轮或者右侧面板‘图纸’栏可控制画布缩放</div>
167
+ <div>在画布空白区使用鼠标滚轮或者右侧面板‘图纸’栏可控制画布缩放</div>
166
168
  <div class="el-divider el-divider--horizontal" role="separator" style="--el-border-style: solid"></div>
167
169
  <div class="font-bold mb-10px text-15px guide-title">标尺辅助线</div>
168
170
  <div>在标尺区域按住鼠标左键并拖动即可创建标尺辅助线,将标尺辅助线拖动到标尺区域即可删除标尺辅助线</div>
@@ -3,29 +3,34 @@
3
3
  import { useGlobalStore } from '@/stores/global'
4
4
  import { EGlobalStoreIntention, EMouseInfoState } from '@/stores/global/types'
5
5
  import type { IDoneJson } from '@/stores/global/types'
6
- import { getCommonClass, prosToVBind, setArrItemByID, stopEvent, valFormat } from '@/utils'
6
+ import {
7
+ componentsRegister,
8
+ getCommonClass,
9
+ preventDefault,
10
+ prosToVBind,
11
+ setArrItemByID,
12
+ setEditorLoadTime,
13
+ stopEvent,
14
+ valFormat
15
+ } from '@/utils'
7
16
 
8
17
  import { EDoneJsonType, EEventAction, EEventType } from '@/config/types'
9
18
  import ConnectionLine from '@/components/svg-editor/connection-line.vue'
10
19
 
11
- import { vueComp } from '@/config'
12
20
  import type { IDataModel } from '@/components/svg-editor/types'
13
21
  import 'element-plus/dist/index.css'
14
22
  import 'animate.css'
15
23
 
16
24
  import { sub, close } from '@/utils/mqtt-net'
17
25
 
26
+ setEditorLoadTime()
27
+
18
28
  const emit = defineEmits(['onMessage'])
19
- //注册所有组件
20
- const instance = getCurrentInstance()
21
- Object.keys(vueComp).forEach((key: string) => {
22
- if (!Object.keys(instance?.appContext?.components as any).includes(key)) {
23
- instance?.appContext.app.component(key, vueComp[key])
24
- }
25
- })
26
29
  const props = withDefaults(defineProps<{ data?: IDataModel; canvasDrag?: boolean }>(), {
27
30
  canvasDrag: true
28
31
  })
32
+ const globalStore = useGlobalStore(pinia)
33
+ componentsRegister()
29
34
  const preview_data = reactive(
30
35
  props.data ?? {
31
36
  layout_center: {
@@ -50,7 +55,6 @@
50
55
  done_json: []
51
56
  }
52
57
  )
53
- const globalStore = useGlobalStore(pinia)
54
58
 
55
59
  const cursor_style = computed(() => (globalStore.intention == EGlobalStoreIntention.MoveCanvas ? 'grab' : 'default'))
56
60
  const onCanvasMouseMove = (e: MouseEvent) => {
@@ -135,9 +139,6 @@
135
139
  height: actual_bound.height * scale_y
136
140
  }
137
141
  }
138
- const setNodeAttrByID = (id: string, attr: string, val: any) => {
139
- return setArrItemByID(id, attr, val, preview_data.done_json)
140
- }
141
142
 
142
143
  const getStyle = (root: IDoneJson) => {
143
144
  let t = false
@@ -241,6 +242,10 @@
241
242
  }
242
243
  }
243
244
 
245
+ const setNodeAttrByID = (id: string, attr: string, val: any) => {
246
+ return setArrItemByID(id, attr, val, preview_data.done_json)
247
+ }
248
+
244
249
  onMounted(() => {
245
250
  connectNet()
246
251
  })
@@ -259,6 +264,7 @@
259
264
  @mousemove="onCanvasMouseMove"
260
265
  @mouseup="onCanvasMouseUp"
261
266
  @mousewheel="onMousewheel"
267
+ @contextmenu="preventDefault"
262
268
  >
263
269
  <svg
264
270
  xmlns="http://www.w3.org/2000/svg"
@@ -326,6 +332,7 @@
326
332
  v-else-if="item.type === EDoneJsonType.Vue"
327
333
  v-bind="getActualBoundScale(item.actual_bound, item.scale_x, item.scale_y)"
328
334
  :id="`foreign-object${item.id}`"
335
+ class="foreignObject"
329
336
  >
330
337
  <component
331
338
  :is="item.tag"
@@ -356,24 +363,6 @@
356
363
  cursor: v-bind('cursor_style');
357
364
  }
358
365
 
359
- .svg-item-none {
360
- cursor: move;
361
-
362
- &:hover {
363
- outline: 1px solid #f8d032;
364
- }
365
- }
366
-
367
- .svg-item-move {
368
- cursor: move;
369
- outline: 1px dashed rgb(149, 23, 222);
370
- }
371
-
372
- .svg-item-select {
373
- cursor: move;
374
- outline: 1px solid rgb(149, 23, 222);
375
- }
376
-
377
366
  .common-ani {
378
367
  transform-box: fill-box;
379
368
  }
@@ -2,7 +2,9 @@
2
2
  import { pinia } from '@/hooks'
3
3
  import { useSvgEditLayoutStore } from '@/stores/svg-edit-layout'
4
4
  import { useConfigStore } from '@/stores/config'
5
+ import { preventDefault, stopEvent } from '@/utils'
5
6
 
7
+ const emit = defineEmits(['onLineMouseUp'])
6
8
  const props = withDefaults(
7
9
  defineProps<{
8
10
  visible?: boolean
@@ -291,6 +293,10 @@
291
293
  dragFlag = 'v'
292
294
  dragLineId = id
293
295
  }
296
+
297
+ const lineMouseUp = () => {
298
+ emit('onLineMouseUp')
299
+ }
294
300
  </script>
295
301
 
296
302
  <template>
@@ -317,6 +323,8 @@
317
323
  :key="item.id"
318
324
  :class="`vue-ruler-ref-line-${item.type}`"
319
325
  @mousedown="handleDragLine(item)"
326
+ @mouseup="lineMouseUp"
327
+ @contextmenu="preventDefault"
320
328
  />
321
329
  </section>
322
330
  <div ref="content" class="vue-ruler-content" :style="contentStyle">
@@ -427,6 +435,7 @@
427
435
  height: 4px;
428
436
  cursor: n-resize;
429
437
  border-top: 1px dashed #999;
438
+
430
439
  span {
431
440
  left: 30px;
432
441
  top: 3px;
@@ -439,6 +448,7 @@
439
448
  _height: 9999px;
440
449
  cursor: w-resize;
441
450
  border-left: 1px dashed #999;
451
+
442
452
  span {
443
453
  top: 30px;
444
454
  left: 7px;