@zhangqingcq/vgce 0.1.3 → 0.1.4

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.1.3",
3
+ "version": "0.1.4",
4
4
  "description": "Vector graphics configure editor. svg组态编辑器。基于vue3.3+ts+element-plus+vite",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -60,7 +60,7 @@
60
60
  "echarts": "^5.4.1",
61
61
  "element-plus": "^2.3.8",
62
62
  "lodash-es": "^4.17.21",
63
- "mqtt": "^4.3.7",
63
+ "mqtt": "^5.1.3",
64
64
  "pinia": "^2.1.3",
65
65
  "vue": "^3.3.4",
66
66
  "vue-echarts": "^6.5.1",
@@ -240,7 +240,7 @@
240
240
  1.用你的项目里前后端约定的svg组件唯一标识符替换掉编辑器生成的id(必须保证唯一),然后调用setNodeAttrByID改变组件属性。
241
241
  2.如果不想改动id(避免因不能保证手动改过的id唯一性导致编辑器功能异常),可以在config里给想要改变的组件的配置文件的props里增加一个字段,
242
242
  如deviceCode(svg-text的配置文件里有被注释的例子),然后在编辑组态时,给对应组件填上对应的deviceCode(这样deviceCode就和组件id实现
243
- 了映射关系),并保存,后台给前台推MQTT消息时带上指定的deviceCode,前台预览时,在收到MQTT消息后,凭借消息里的deviceCode找在done_json
243
+ 了映射关系),并保存,后台给前台推MQTT消息时带上指定的deviceCode,前台预览时,在收到MQTT消息后,凭借消息里的deviceCodedone_json
244
244
  找到组件的id(可以用vue的computed计算一份deviceCode和id的映射关系存到一个对象里,这样在需要id时可直接在计算出的对象凭借deviceCode
245
245
  直接取到),即可用setNodeAttrByID改变组件属性*/
246
246
  emit('onMessage', {
@@ -4,9 +4,14 @@ import type { MqttClient, PacketCallback } from 'mqtt'
4
4
  let client: MqttClient
5
5
 
6
6
  export const sub = (url: string, user: string, pwd: string, topics: string, callback: Function) => {
7
- client = connect(url, {
8
- username: user,
9
- password: pwd,
7
+ const _url = url.trim()
8
+ if (!/^wss?:\/\/.*$/.test(_url)) {
9
+ console.error('编辑器MQTT通信只支持ws协议 (url必须以"ws://"开头)')
10
+ return
11
+ }
12
+ client = connect(_url, {
13
+ username: user.trim(),
14
+ password: pwd.trim(),
10
15
  reconnectPeriod: 600000 /*如果连不上,10分钟后重试*/
11
16
  })
12
17
 
@@ -20,9 +25,14 @@ export const sub = (url: string, user: string, pwd: string, topics: string, call
20
25
  }
21
26
 
22
27
  export const pub = (url: string, user: string, pwd: string, topics: string, data: any, callback: PacketCallback) => {
23
- client = connect(url, {
24
- username: user,
25
- password: pwd
28
+ const _url = url.trim()
29
+ if (!/^wss?:\/\/.*$/.test(_url)) {
30
+ console.error('编辑器MQTT通信只支持ws协议 (url必须以"ws://"开头)')
31
+ return
32
+ }
33
+ client = connect(_url, {
34
+ username: user.trim(),
35
+ password: pwd.trim()
26
36
  })
27
37
 
28
38
  client.on('connect', () => {