@zhangqingcq/vgce 0.1.4 → 0.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zhangqingcq/vgce",
3
- "version": "0.1.4",
3
+ "version": "0.1.6",
4
4
  "description": "Vector graphics configure editor. svg组态编辑器。基于vue3.3+ts+element-plus+vite",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -1005,9 +1005,9 @@
1005
1005
  <use
1006
1006
  v-else-if="item.type === EDoneJsonType.File"
1007
1007
  :xlink:href="`#svg-${item.name}`"
1008
- v-bind="prosToVBind(item)"
1009
- width="100"
1010
- height="100"
1008
+ v-bind="prosToVBind(item, ['height', 'width'])"
1009
+ :width="item.props?.width?.val ?? 100"
1010
+ :height="item.props?.height?.val ?? 100"
1011
1011
  :id="item.id"
1012
1012
  :transform="`translate(${item.actual_bound.x + item.actual_bound.width / 2},${
1013
1013
  item.actual_bound.y + item.actual_bound.height / 2
@@ -1019,9 +1019,9 @@
1019
1019
  <component
1020
1020
  v-else-if="item.type === EDoneJsonType.CustomSvg"
1021
1021
  :is="item.tag"
1022
- v-bind="prosToVBind(item)"
1023
- width="100"
1024
- height="100"
1022
+ v-bind="prosToVBind(item, ['height', 'width'])"
1023
+ :width="item.props?.width?.val ?? 100"
1024
+ :height="item.props?.height?.val ?? 100"
1025
1025
  :id="item.id"
1026
1026
  @resize="resizeBox"
1027
1027
  :transform="`translate(${item.actual_bound.x + item.actual_bound.width / 2},${
@@ -1,5 +1,6 @@
1
1
  <!--左侧工具栏-->
2
2
  <script lang="ts" setup>
3
+ import { isEmpty } from 'lodash-es'
3
4
  import { ElCollapse, ElCollapseItem, ElIcon, ElMessage } from 'element-plus'
4
5
  import type { IConfig, IConfigItem } from '@/config/types'
5
6
  import { pinia } from '@/hooks'
@@ -23,7 +24,16 @@
23
24
  'echarts'
24
25
  ])
25
26
  const createBegin = (svg_item: IConfigItem) => {
26
- globalStore.setCreateInfo(svg_item)
27
+ globalStore.setCreateInfo(sortProps(svg_item))
28
+ }
29
+
30
+ const sortProps = (svg_item: IConfigItem): IConfigItem => {
31
+ if (svg_item?.props && !isEmpty(svg_item.props)) {
32
+ Object.keys(svg_item.props).forEach((k, i) => {
33
+ svg_item.props[k].sort = String(i)
34
+ })
35
+ }
36
+ return svg_item
27
37
  }
28
38
  const dragEndEvent = (e: DragEvent) => {
29
39
  //拖动时记录拖动的svg信息
@@ -21,6 +21,38 @@
21
21
  code: false
22
22
  })
23
23
 
24
+ const _objInfo = computed(() => {
25
+ const keys: Record<string, any> = {}
26
+ let l = 0
27
+ let t = []
28
+ for (let k of Object.keys(props.objInfo)) {
29
+ const s = props.objInfo[k]?.sort
30
+ if (s) {
31
+ const _s = Number(s)
32
+ if (_s > l) {
33
+ l = _s
34
+ }
35
+ }
36
+ if (s) {
37
+ keys[s] = k
38
+ } else {
39
+ return Object.keys(props.objInfo).map((k) => ({
40
+ ...props.objInfo[k],
41
+ _key: k
42
+ }))
43
+ }
44
+ }
45
+
46
+ for (let i = 0; i < l + 1; i++) {
47
+ const _i = String(i)
48
+ t.push({
49
+ ...props.objInfo[keys[_i]],
50
+ _key: keys[_i]
51
+ })
52
+ }
53
+ return t
54
+ })
55
+
24
56
  function propsChangeHandle(e: any) {
25
57
  let t: any = window.setTimeout(function () {
26
58
  emit('change', e)
@@ -31,19 +63,19 @@
31
63
  </script>
32
64
 
33
65
  <template>
34
- <div v-for="(attr_item, key) in props.objInfo" :key="key">
66
+ <div v-for="attr_item in _objInfo" :key="attr_item._key">
35
67
  <!--表单项上显示的灰色值-->
36
68
  <el-form-item v-if="props.code" class="props-row" size="small">
37
69
  <template #label>
38
70
  <el-tooltip
39
- :content="String(key)"
40
- v-if="getStringWidth(String(key)) > 78"
71
+ :content="String(attr_item._key)"
72
+ v-if="getStringWidth(String(attr_item._key)) > 78"
41
73
  placement="left"
42
74
  popper-class="props-popper"
43
75
  >
44
- <div class="one-row-txt" style="width: 78px">{{ key }}</div>
76
+ <div class="one-row-txt" style="width: 78px">{{ attr_item._key }}</div>
45
77
  </el-tooltip>
46
- <span v-else>{{ key }}</span>
78
+ <span v-else>{{ attr_item._key }}</span>
47
79
  </template>
48
80
  <el-tooltip
49
81
  :content="JSON.stringify(attr_item.val)"
@@ -56,10 +88,10 @@
56
88
  <span v-else>{{ attr_item.val }}</span>
57
89
  </el-form-item>
58
90
  <!--props-->
59
- <el-form-item :label="attr_item.title" size="small" v-if="props.hide.indexOf(String(key)) < 0">
91
+ <el-form-item :label="attr_item.title" size="small" v-if="props.hide.indexOf(String(attr_item._key)) < 0">
60
92
  <el-select
61
93
  v-if="attr_item.type === EConfigItemPropsType.Select"
62
- v-model="attr_item.val"
94
+ v-model="props.objInfo[attr_item._key].val"
63
95
  placeholder="Select"
64
96
  size="small"
65
97
  :disabled="Boolean(attr_item?.disabled)"
@@ -69,19 +101,19 @@
69
101
  </el-select>
70
102
  <el-input-number
71
103
  v-else-if="attr_item.type === EConfigItemPropsType.InputNumber"
72
- v-model="attr_item.val"
104
+ v-model="props.objInfo[attr_item._key].val"
73
105
  :disabled="Boolean(attr_item?.disabled)"
74
106
  @change="propsChangeHandle"
75
107
  />
76
108
  <el-input
77
109
  v-else-if="attr_item.type === EConfigItemPropsType.Input"
78
- v-model="attr_item.val"
110
+ v-model="props.objInfo[attr_item._key].val"
79
111
  :disabled="Boolean(attr_item?.disabled)"
80
112
  @change="propsChangeHandle"
81
113
  />
82
114
  <el-input
83
115
  v-else-if="attr_item.type === EConfigItemPropsType.Textarea"
84
- v-model="attr_item.val"
116
+ v-model="props.objInfo[attr_item._key].val"
85
117
  autosize
86
118
  type="textarea"
87
119
  :disabled="Boolean(attr_item?.disabled)"
@@ -89,19 +121,19 @@
89
121
  />
90
122
  <el-color-picker
91
123
  v-else-if="attr_item.type === EConfigItemPropsType.Color"
92
- v-model="attr_item.val"
124
+ v-model="props.objInfo[attr_item._key].val"
93
125
  :disabled="Boolean(attr_item?.disabled)"
94
126
  @change="propsChangeHandle"
95
127
  />
96
128
  <el-switch
97
129
  v-else-if="attr_item.type === EConfigItemPropsType.Switch"
98
- v-model="attr_item.val"
130
+ v-model="props.objInfo[attr_item._key].val"
99
131
  :disabled="Boolean(attr_item?.disabled)"
100
132
  @change="propsChangeHandle"
101
133
  />
102
134
  <code-edit-modal
103
135
  v-else-if="attr_item.type === EConfigItemPropsType.JsonEdit"
104
- v-model="attr_item.val"
136
+ v-model="props.objInfo[attr_item._key].val"
105
137
  :disabled="Boolean(attr_item?.disabled)"
106
138
  @close="propsChangeHandle"
107
139
  />
@@ -119,8 +151,4 @@
119
151
  .props-popper {
120
152
  max-width: 350px;
121
153
  }
122
- sdf {
123
- color: rgb(245, 247, 250);
124
- background-color: rgb(92, 184, 122);
125
- }
126
154
  </style>
@@ -318,9 +318,9 @@
318
318
  <use
319
319
  v-else-if="item.type === EDoneJsonType.File"
320
320
  :xlink:href="`#svg-${item.name}`"
321
- v-bind="prosToVBind(item)"
322
- width="100"
323
- height="100"
321
+ v-bind="prosToVBind(item, ['height', 'width'])"
322
+ :width="item.props?.width?.val ?? 100"
323
+ :height="item.props?.height?.val ?? 100"
324
324
  :id="item.id"
325
325
  :transform="`translate(${item.actual_bound.x + item.actual_bound.width / 2},${
326
326
  item.actual_bound.y + item.actual_bound.height / 2
@@ -332,9 +332,9 @@
332
332
  <component
333
333
  v-else-if="item.type === EDoneJsonType.CustomSvg"
334
334
  :is="item.tag"
335
- v-bind="prosToVBind(item)"
336
- width="100"
337
- height="100"
335
+ v-bind="prosToVBind(item, ['height', 'width'])"
336
+ :width="item.props?.width?.val ?? 100"
337
+ :height="item.props?.height?.val ?? 100"
338
338
  :id="item.id"
339
339
  @on-change="eventHandle(item, EEventType.Change)"
340
340
  :transform="`translate(${item.actual_bound.x + item.actual_bound.width / 2},${
@@ -1,7 +1,9 @@
1
1
  <script setup lang="ts">
2
- const props = withDefaults(defineProps<{ id: string; isOpen: boolean }>(), {
2
+ const props = withDefaults(defineProps<{ id: string; isOpen: boolean; height?: number; width?: number }>(), {
3
3
  id: '',
4
- isOpen: false
4
+ isOpen: false,
5
+ height: 100,
6
+ width: 100
5
7
  })
6
8
 
7
9
  const emit = defineEmits(['onChange'])
@@ -65,6 +67,6 @@
65
67
  fill="#CEEFF6"
66
68
  />
67
69
  </symbol>
68
- <use :xlink:href="`#${props.id}light-121`" width="100" height="100" />
70
+ <use :xlink:href="`#${props.id}light-121`" :width="width" :height="height" />
69
71
  </g>
70
72
  </template>
@@ -1,4 +1,4 @@
1
- import { EConfigItemPropsType, EDoneJsonType } from '@/config/types'
1
+ import { EDoneJsonType } from '@/config/types'
2
2
  import type { IConfigItem } from '@/config/types'
3
3
  export const thermometer: IConfigItem = {
4
4
  name: 'thermometer',
@@ -49,7 +49,7 @@ export const clock_a: IConfigItem = {
49
49
  val: '#ffffff'
50
50
  },
51
51
  borderColor: {
52
- title: '裱框颜色',
52
+ title: '表框颜色',
53
53
  type: EConfigItemPropsType.Color,
54
54
  val: '#B3A7FF'
55
55
  }
@@ -13,6 +13,16 @@ export const light_a: IConfigItem = {
13
13
  },
14
14
  display: true,
15
15
  props: {
16
+ height: {
17
+ title: '高度',
18
+ type: EConfigItemPropsType.InputNumber,
19
+ val: 60
20
+ },
21
+ width: {
22
+ title: '宽度',
23
+ type: EConfigItemPropsType.InputNumber,
24
+ val: 50
25
+ },
16
26
  isOpen: {
17
27
  title: '开关',
18
28
  type: EConfigItemPropsType.Switch,
@@ -1,4 +1,4 @@
1
- import { EDoneJsonType } from '@/config/types'
1
+ import { EConfigItemPropsType, EDoneJsonType } from '@/config/types'
2
2
  import type { IConfigItem } from '@/config/types'
3
3
 
4
4
  export const svg_bot_2: IConfigItem = {
@@ -11,7 +11,18 @@ export const svg_bot_2: IConfigItem = {
11
11
  have_anchor: true,
12
12
  actual_rect: true
13
13
  },
14
- props: {},
14
+ props: {
15
+ height: {
16
+ title: '高度',
17
+ type: EConfigItemPropsType.InputNumber,
18
+ val: 150
19
+ },
20
+ width: {
21
+ title: '宽度',
22
+ type: EConfigItemPropsType.InputNumber,
23
+ val: 120
24
+ }
25
+ },
15
26
  common_animations: {
16
27
  val: '',
17
28
  delay: 'delay-0s',
@@ -36,6 +36,7 @@ export interface IConfigItemProps {
36
36
  val: any
37
37
  options?: any
38
38
  disabled?: boolean
39
+ sort?: string
39
40
  }
40
41
  }
41
42
 
@@ -3,7 +3,7 @@ import type { MqttClient, PacketCallback } from 'mqtt'
3
3
 
4
4
  let client: MqttClient
5
5
 
6
- export const sub = (url: string, user: string, pwd: string, topics: string, callback: Function) => {
6
+ export const sub = (url: string, user: string, pwd: string, topics: string, callback: any) => {
7
7
  const _url = url.trim()
8
8
  if (!/^wss?:\/\/.*$/.test(_url)) {
9
9
  console.error('编辑器MQTT通信只支持ws协议 (url必须以"ws://"开头)')