@zhangqingcq/vgce 0.0.14 → 0.0.15
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +3 -1
- package/dist/vgce.js +5 -12
- package/dist/vgce.umd.cjs +2 -2
- package/package.json +3 -2
- package/src/App.vue +11 -0
- package/src/assets/base.less +49 -0
- package/src/assets/icons/add.svg +1 -0
- package/src/assets/icons/delete.svg +12 -0
- package/src/assets/icons/export.svg +1 -0
- package/src/assets/icons/group.svg +13 -0
- package/src/assets/icons/import.svg +1 -0
- package/src/assets/icons/lock.svg +7 -0
- package/src/assets/icons/menu-fold.svg +9 -0
- package/src/assets/icons/menu-unfold.svg +9 -0
- package/src/assets/icons/preview.svg +6 -0
- package/src/assets/icons/redo.svg +8 -0
- package/src/assets/icons/return.svg +8 -0
- package/src/assets/icons/rotate.svg +1 -0
- package/src/assets/icons/save.svg +9 -0
- package/src/assets/icons/setting.svg +6 -0
- package/src/assets/icons/undo.svg +7 -0
- package/src/assets/icons/ungroup.svg +16 -0
- package/src/assets/icons/unlock.svg +7 -0
- package/src/assets/main.less +6 -0
- package/src/assets/svgs/alternator.svg +8 -0
- package/src/assets/svgs/bot-12.svg +1 -0
- package/src/assets/svgs/bot-2.svg +1 -0
- package/src/assets/svgs/bot-3.svg +1 -0
- package/src/assets/svgs/bot-7.svg +1 -0
- package/src/assets/svgs/bot-9.svg +94 -0
- package/src/assets/svgs/car.svg +1 -0
- package/src/assets/svgs/circuit-breaker.svg +11 -0
- package/src/assets/svgs/clock-a.svg +23 -0
- package/src/assets/svgs/common-table.svg +7 -0
- package/src/assets/svgs/el-button.svg +10 -0
- package/src/assets/svgs/el-tag.svg +13 -0
- package/src/assets/svgs/hospital.svg +1 -0
- package/src/assets/svgs/house.svg +1 -0
- package/src/assets/svgs/light.svg +24 -0
- package/src/assets/svgs/now-time.svg +9 -0
- package/src/assets/svgs/package.svg +1 -0
- package/src/assets/svgs/pie-charts.svg +10 -0
- package/src/assets/svgs/progress-a.svg +1 -0
- package/src/assets/svgs/reservoir.svg +10 -0
- package/src/assets/svgs/svg-text.svg +5 -0
- package/src/assets/svgs/switch-a.svg +5 -0
- package/src/assets/svgs/traction-transformer.svg +11 -0
- package/src/components/ace-edit/index.ts +27 -0
- package/src/components/config/index.ts +450 -0
- package/src/components/config/types.ts +25 -0
- package/src/components/svg-analysis/index.vue +11 -0
- package/src/components/svg-editor/center-panel/index.vue +867 -0
- package/src/components/svg-editor/center-panel/types.ts +11 -0
- package/src/components/svg-editor/component-tree/index.vue +33 -0
- package/src/components/svg-editor/connection-line/index.vue +125 -0
- package/src/components/svg-editor/connection-panel/index.vue +198 -0
- package/src/components/svg-editor/export-json/index.vue +37 -0
- package/src/components/svg-editor/handle-panel/index.vue +342 -0
- package/src/components/svg-editor/import-json/index.vue +37 -0
- package/src/components/svg-editor/index.vue +280 -0
- package/src/components/svg-editor/left-panel/index.vue +83 -0
- package/src/components/svg-editor/right-panel/code-edit-modal.vue +50 -0
- package/src/components/svg-editor/right-panel/common-animate.vue +96 -0
- package/src/components/svg-editor/right-panel/condition.vue +101 -0
- package/src/components/svg-editor/right-panel/dynamic-el-form-item.vue +97 -0
- package/src/components/svg-editor/right-panel/index.vue +304 -0
- package/src/components/svg-editor/right-panel/list.vue +86 -0
- package/src/components/svg-editor/top-panel/index.vue +139 -0
- package/src/components/svg-editor/types.ts +22 -0
- package/src/components/svg-viewer/index.vue +340 -0
- package/src/components/vue3-ruler-tool/index.vue +506 -0
- package/src/config/files/clock-a.vue +66 -0
- package/src/config/files/common-table.vue +49 -0
- package/src/config/files/light-a.vue +72 -0
- package/src/config/files/now-time.vue +53 -0
- package/src/config/files/pie-charts.vue +72 -0
- package/src/config/files/progress.vue +40 -0
- package/src/config/files/svg-text.vue +39 -0
- package/src/config/files/switch-a.vue +45 -0
- package/src/config/index.ts +28 -0
- package/src/config/svg/animation/index.ts +8 -0
- package/src/config/svg/animation/reservoir.ts +32 -0
- package/src/config/svg/custom/clock-a.ts +23 -0
- package/src/config/svg/custom/index.ts +11 -0
- package/src/config/svg/custom/light.ts +29 -0
- package/src/config/svg/custom/svg-text.ts +54 -0
- package/src/config/svg/custom/switch-a.ts +29 -0
- package/src/config/svg/index.ts +12 -0
- package/src/config/svg/stateful/circuit-breaker.ts +38 -0
- package/src/config/svg/stateful/index.ts +8 -0
- package/src/config/svg/stateless/alternator.ts +28 -0
- package/src/config/svg/stateless/bot-12.ts +22 -0
- package/src/config/svg/stateless/bot-2.ts +22 -0
- package/src/config/svg/stateless/bot-3.ts +22 -0
- package/src/config/svg/stateless/bot-7.ts +22 -0
- package/src/config/svg/stateless/bot-9.ts +22 -0
- package/src/config/svg/stateless/car.ts +22 -0
- package/src/config/svg/stateless/hospital.ts +22 -0
- package/src/config/svg/stateless/house.ts +22 -0
- package/src/config/svg/stateless/index.ts +30 -0
- package/src/config/svg/stateless/package.ts +22 -0
- package/src/config/svg/stateless/traction-transformer.ts +28 -0
- package/src/config/types.ts +126 -0
- package/src/config/vue/component/button.ts +57 -0
- package/src/config/vue/component/common-table.ts +124 -0
- package/src/config/vue/component/index.ts +13 -0
- package/src/config/vue/component/now-time.ts +29 -0
- package/src/config/vue/component/progress.ts +29 -0
- package/src/config/vue/component/tag.ts +46 -0
- package/src/config/vue/echarts/index.ts +8 -0
- package/src/config/vue/echarts/pie-charts.ts +60 -0
- package/src/config/vue/index.ts +5 -0
- package/src/hooks.ts +47 -0
- package/src/index.ts +14 -0
- package/src/main.ts +15 -0
- package/src/router.ts +24 -0
- package/src/stores/config/index.ts +44 -0
- package/src/stores/config/types.ts +27 -0
- package/src/stores/global/index.ts +109 -0
- package/src/stores/global/types.ts +115 -0
- package/src/stores/main.ts +10 -0
- package/src/stores/svg-edit-layout/index.ts +17 -0
- package/src/stores/svg-edit-layout/types.ts +8 -0
- package/src/stores/system/index.ts +174 -0
- package/src/stores/system/types.ts +43 -0
- package/src/utils/fetch.ts +351 -0
- package/src/utils/file-read-write.ts +26 -0
- package/src/utils/index.ts +397 -0
- package/src/utils/mqtt-net.ts +48 -0
- package/src/utils/proxy.ts +7 -0
- package/src/utils/scale-core.ts +214 -0
- package/src/utils/types.ts +13 -0
- package/src/views/EditorS.vue +18 -0
- package/src/views/Preview.vue +12 -0
@@ -0,0 +1,351 @@
|
|
1
|
+
/**
|
2
|
+
* @description 基于axios的网络请求插件
|
3
|
+
* @author Ricky email:zhangqingcq@foxmail.com
|
4
|
+
* @created 2023.06.21
|
5
|
+
*/
|
6
|
+
import axios from 'axios'
|
7
|
+
import type { AxiosInstance, AxiosRequestConfig, AxiosResponse } from 'axios'
|
8
|
+
import _ from 'lodash'
|
9
|
+
|
10
|
+
import type { Collection } from './types'
|
11
|
+
|
12
|
+
// const host = window.location.origin
|
13
|
+
const host = 'http://localhost:6789'
|
14
|
+
|
15
|
+
interface RequestConfigR extends AxiosRequestConfig {
|
16
|
+
spin?: boolean
|
17
|
+
noEmptyStr?: boolean
|
18
|
+
}
|
19
|
+
|
20
|
+
// 创建自定义对象
|
21
|
+
let service: AxiosInstance = axios.create({
|
22
|
+
baseURL: host,
|
23
|
+
withCredentials: true // 允许携带cookie
|
24
|
+
})
|
25
|
+
|
26
|
+
/**
|
27
|
+
* 拦截器,在发起请求前调用
|
28
|
+
*/
|
29
|
+
service.interceptors.request.use(
|
30
|
+
(q) => {
|
31
|
+
return q
|
32
|
+
},
|
33
|
+
(e) => {
|
34
|
+
return Promise.reject(e)
|
35
|
+
}
|
36
|
+
)
|
37
|
+
|
38
|
+
/**
|
39
|
+
* 封装请求结果和错误处理
|
40
|
+
*/
|
41
|
+
function checkResult(r: Partial<AxiosResponse>, msg?: string, rPath?: string[], config?: RequestConfigR) {
|
42
|
+
let y = true
|
43
|
+
let d = r && r.data
|
44
|
+
if (d) {
|
45
|
+
rPath = rPath ? rPath : []
|
46
|
+
for (let e of rPath) {
|
47
|
+
d = d[e]
|
48
|
+
y = y && d
|
49
|
+
}
|
50
|
+
if (y) {
|
51
|
+
return d
|
52
|
+
}
|
53
|
+
msg && console.warn(msg)
|
54
|
+
return false
|
55
|
+
}
|
56
|
+
msg && console.warn(msg)
|
57
|
+
return false
|
58
|
+
}
|
59
|
+
|
60
|
+
function handleRequest(
|
61
|
+
method: string,
|
62
|
+
url: string,
|
63
|
+
data?: Collection,
|
64
|
+
msg?: string,
|
65
|
+
rPath?: string[],
|
66
|
+
config?: RequestConfigR,
|
67
|
+
isUrlData?: boolean
|
68
|
+
) {
|
69
|
+
return new Promise((s, j) => {
|
70
|
+
switch (method) {
|
71
|
+
case 'get':
|
72
|
+
service
|
73
|
+
.get(url, { params: data })
|
74
|
+
.then((r) => {
|
75
|
+
let d = checkResult(r, msg, rPath, config)
|
76
|
+
if (d) {
|
77
|
+
s(d)
|
78
|
+
} else {
|
79
|
+
j(r)
|
80
|
+
}
|
81
|
+
})
|
82
|
+
.catch((e) => {
|
83
|
+
checkResult({}, msg, rPath, config)
|
84
|
+
j(e)
|
85
|
+
})
|
86
|
+
break
|
87
|
+
case 'delete':
|
88
|
+
let keyT = isUrlData ? 'params' : 'data'
|
89
|
+
service
|
90
|
+
.delete(url, { [keyT]: data })
|
91
|
+
.then((r) => {
|
92
|
+
let d = checkResult(r, msg, rPath, config)
|
93
|
+
if (d) {
|
94
|
+
s(d)
|
95
|
+
} else {
|
96
|
+
j(r)
|
97
|
+
}
|
98
|
+
})
|
99
|
+
.catch((e) => {
|
100
|
+
checkResult({}, msg, rPath, config)
|
101
|
+
j(e)
|
102
|
+
})
|
103
|
+
break
|
104
|
+
case 'post':
|
105
|
+
service
|
106
|
+
.post(url, data, config)
|
107
|
+
.then((r) => {
|
108
|
+
let d = checkResult(r, msg, rPath, config)
|
109
|
+
if (d) {
|
110
|
+
s(d)
|
111
|
+
} else {
|
112
|
+
j(r)
|
113
|
+
}
|
114
|
+
})
|
115
|
+
.catch((e) => {
|
116
|
+
checkResult({}, msg, rPath, config)
|
117
|
+
j(e)
|
118
|
+
})
|
119
|
+
break
|
120
|
+
case 'put':
|
121
|
+
service
|
122
|
+
.put(url, data, config)
|
123
|
+
.then((r) => {
|
124
|
+
let d = checkResult(r, msg, rPath, config)
|
125
|
+
if (d) {
|
126
|
+
s(d)
|
127
|
+
} else {
|
128
|
+
j(r)
|
129
|
+
}
|
130
|
+
})
|
131
|
+
.catch((e) => {
|
132
|
+
checkResult({}, msg, rPath, config)
|
133
|
+
j(e)
|
134
|
+
})
|
135
|
+
break
|
136
|
+
default:
|
137
|
+
}
|
138
|
+
})
|
139
|
+
}
|
140
|
+
|
141
|
+
/**
|
142
|
+
* 检查请求传入的各个参数
|
143
|
+
* @param method 请求方法
|
144
|
+
* @param url 地址
|
145
|
+
* @param data 餐宿
|
146
|
+
* @param msg 错误信息
|
147
|
+
* @param rPath 返回数据路径(提取)
|
148
|
+
* @param config 请求配置
|
149
|
+
* @param isUrlData delete方法传参模式 true:params,false:data
|
150
|
+
* @returns {Promise<*>}
|
151
|
+
*/
|
152
|
+
function checkRequest(
|
153
|
+
method: string,
|
154
|
+
url: string,
|
155
|
+
data: Collection = {},
|
156
|
+
msg?: string,
|
157
|
+
rPath?: string[],
|
158
|
+
config?: RequestConfigR,
|
159
|
+
isUrlData?: boolean
|
160
|
+
) {
|
161
|
+
return new Promise((s, j) => {
|
162
|
+
if (url) {
|
163
|
+
let data_: Collection | undefined
|
164
|
+
if (config && config.headers && config.headers['Content-Type'] === 'multipart/form-data') {
|
165
|
+
data_ = data
|
166
|
+
} else {
|
167
|
+
if (data && !_.isEmpty(data)) {
|
168
|
+
if (Array.isArray(data)) {
|
169
|
+
data_ = []
|
170
|
+
for (let e of data) {
|
171
|
+
if (e || e === 0 || e === false || (e === '' && config && !config.noEmptyStr)) {
|
172
|
+
data_.push(e)
|
173
|
+
}
|
174
|
+
}
|
175
|
+
} else {
|
176
|
+
data_ = {}
|
177
|
+
for (let key in data) {
|
178
|
+
if (
|
179
|
+
data.hasOwnProperty(key) &&
|
180
|
+
(data[key] ||
|
181
|
+
data[key] === 0 ||
|
182
|
+
data[key] === false ||
|
183
|
+
(data[key] === '' && config && !config.noEmptyStr))
|
184
|
+
) {
|
185
|
+
data_[key] = data[key]
|
186
|
+
}
|
187
|
+
}
|
188
|
+
}
|
189
|
+
}
|
190
|
+
}
|
191
|
+
let method_ = method.toLowerCase()
|
192
|
+
handleRequest(method_, url, data_, msg, rPath, config, isUrlData)
|
193
|
+
.then((r) => {
|
194
|
+
s(r)
|
195
|
+
})
|
196
|
+
.catch((e) => {
|
197
|
+
j(e)
|
198
|
+
})
|
199
|
+
} else {
|
200
|
+
console.error('没有请求地址:url')
|
201
|
+
j('没有请求地址:url')
|
202
|
+
}
|
203
|
+
})
|
204
|
+
}
|
205
|
+
|
206
|
+
/**
|
207
|
+
* @description 基于axios封装的请求插件,引入库时使用this.$fetch时直接调用以下方法,例如:this.$fetch.get("/getData",{id:1}),
|
208
|
+
* vue3的setup模式使用:proxy调用
|
209
|
+
* 单独引入时遵循Es Modules规范即可
|
210
|
+
* @class
|
211
|
+
*/
|
212
|
+
export default {
|
213
|
+
/**
|
214
|
+
* post 请求
|
215
|
+
* @function
|
216
|
+
* @param {string} url 请求地址
|
217
|
+
* @param {object} data 请求数据
|
218
|
+
* @param {string} msg 错误信息,在控制台输出,方便调试,不用可以不传,例如:
|
219
|
+
* @example this.$fetch.post("/getDataB",{name:'ricky'},"获取数据B失败")
|
220
|
+
* @param {Array.<string>} rPath 请求结果提取路径,如:[data,list]表示data.list,如不需过滤可不传
|
221
|
+
* @param {object} config 请求配置 如请求过程需要遮罩层,设置 spin:true即可
|
222
|
+
* @return {Promise<object>}
|
223
|
+
* @example this.$fetch.post("/getData",{id:1},null,['result','list'])
|
224
|
+
* .then(r=>{
|
225
|
+
* console.log(r)
|
226
|
+
* r相当于:data.result.list,data是网络请求结果
|
227
|
+
* })
|
228
|
+
*
|
229
|
+
* 注意:
|
230
|
+
* 请求最多支持5个入参,最少一个(url),依次为:url,data,msg,rPath,config。如果要传靠后的入参,但不想传前面的,应该这样传:
|
231
|
+
* this.$fetch.post("/setData",{},null,[],{
|
232
|
+
* headers: {
|
233
|
+
* 'Content-Type': 'multipart/form-data'
|
234
|
+
* },
|
235
|
+
* spin:true
|
236
|
+
* }
|
237
|
+
* )
|
238
|
+
*/
|
239
|
+
post(url: string, data?: Collection, msg?: string, rPath?: string[], config?: RequestConfigR) {
|
240
|
+
return new Promise((s, j) => {
|
241
|
+
checkRequest('post', url, data, msg, rPath, config)
|
242
|
+
.then((r) => {
|
243
|
+
s(r)
|
244
|
+
})
|
245
|
+
.catch((e) => {
|
246
|
+
j(e)
|
247
|
+
})
|
248
|
+
})
|
249
|
+
},
|
250
|
+
/**
|
251
|
+
* put请求
|
252
|
+
* @param {string} url 请求地址
|
253
|
+
* @param {object} data 请求数据
|
254
|
+
* @param {string} msg 错误信息,在控制台输出,方便调试,不用可以不传
|
255
|
+
* @param {Array.<string>} rPath 请求结果提取路径
|
256
|
+
* @param {object} config 请求配置 如请求过程需要遮罩层,设置 spin:true即可
|
257
|
+
* @return {Promise<unknown>}
|
258
|
+
*/
|
259
|
+
put(url: string, data?: Collection, msg?: string, rPath?: string[], config?: RequestConfigR) {
|
260
|
+
return new Promise((s, j) => {
|
261
|
+
checkRequest('put', url, data, msg, rPath, config)
|
262
|
+
.then((r) => {
|
263
|
+
s(r)
|
264
|
+
})
|
265
|
+
.catch((e) => {
|
266
|
+
j(e)
|
267
|
+
})
|
268
|
+
})
|
269
|
+
},
|
270
|
+
/**
|
271
|
+
* get请求
|
272
|
+
* @param {string} url 请求地址
|
273
|
+
* @param {object} data 请求数据
|
274
|
+
* @param {string} msg 错误信息,在控制台输出,方便调试,不用可以不传
|
275
|
+
* @param {Array.<string>} rPath 请求结果提取路径
|
276
|
+
* @param {object} config 请求配置 如请求过程需要遮罩层,设置 spin:true即可
|
277
|
+
* @return {Promise<unknown>}
|
278
|
+
* PS: get请求时(delete请求同理),可以把请求参数写在url里,也可以写在data里,注意写在data里时,data是对象
|
279
|
+
* 以请求'/devices',找到id=2,name=meter举例:
|
280
|
+
* 只传url时,url = '/devices?id=2&name=meter'
|
281
|
+
* url和data都传时,url = '/devices',data={id:2,name:'meter'}
|
282
|
+
*/
|
283
|
+
get(url: string, data?: Collection, msg?: string, rPath?: string[], config?: RequestConfigR) {
|
284
|
+
return new Promise((s, j) => {
|
285
|
+
checkRequest('get', url, data, msg, rPath, config)
|
286
|
+
.then((r) => {
|
287
|
+
s(r)
|
288
|
+
})
|
289
|
+
.catch((e) => {
|
290
|
+
j(e)
|
291
|
+
})
|
292
|
+
})
|
293
|
+
},
|
294
|
+
/**
|
295
|
+
* delete 请求
|
296
|
+
* @param {string} url 请求地址
|
297
|
+
* @param {object} data 请求数据
|
298
|
+
* @param {string} msg 错误信息,在控制台输出,方便调试,不用可以不传
|
299
|
+
* @param {Array.<string>} rPath 请求结果提取路径
|
300
|
+
* @param {object} config 请求配置 如请求过程需要遮罩层,设置 spin:true即可
|
301
|
+
* @param isUrlData 传参模式 true:params,false:data
|
302
|
+
* @return {Promise<unknown>}
|
303
|
+
*/
|
304
|
+
delete(
|
305
|
+
url: string,
|
306
|
+
data?: Collection,
|
307
|
+
msg?: string,
|
308
|
+
rPath?: string[],
|
309
|
+
config?: RequestConfigR,
|
310
|
+
isUrlData: boolean = true
|
311
|
+
) {
|
312
|
+
return new Promise((s, j) => {
|
313
|
+
checkRequest('delete', url, data, msg, rPath, config, isUrlData)
|
314
|
+
.then((r) => {
|
315
|
+
s(r)
|
316
|
+
})
|
317
|
+
.catch((e) => {
|
318
|
+
j(e)
|
319
|
+
})
|
320
|
+
})
|
321
|
+
},
|
322
|
+
/**
|
323
|
+
* 并发请求 例如:
|
324
|
+
* @example this.$fetch.all(
|
325
|
+
* [
|
326
|
+
* this.$fetch.get("/getData"),
|
327
|
+
* this.$fetch.post("/getDataB",{name:'ricky'})
|
328
|
+
* ]
|
329
|
+
* )
|
330
|
+
*/
|
331
|
+
all: axios.all,
|
332
|
+
/**
|
333
|
+
* 并发请求结果分离 例如:
|
334
|
+
* @example this.$fetch.all(
|
335
|
+
* [
|
336
|
+
* this.$fetch.get("/getData"),
|
337
|
+
* this.$fetch.post("/getDataB",{name:'ricky'})
|
338
|
+
* ]
|
339
|
+
* )
|
340
|
+
* .then(
|
341
|
+
* this.$fetch.spread((result1,result2)=>{
|
342
|
+
* console.log(result1,result2)
|
343
|
+
* })
|
344
|
+
* )
|
345
|
+
*/
|
346
|
+
spread: axios.spread,
|
347
|
+
/**
|
348
|
+
* 该请求插件暴露给外界的配置对象,为axios.create创建的实例对象,使用方法见axios官方网站
|
349
|
+
*/
|
350
|
+
config: service
|
351
|
+
}
|
@@ -0,0 +1,26 @@
|
|
1
|
+
export function fileWrite(d: any, name = new Date(Date.now()).toLocaleString()) {
|
2
|
+
const t = JSON.stringify(d)
|
3
|
+
const blob = new Blob([t])
|
4
|
+
let l = document.createElement('a')
|
5
|
+
l.download = name + '.json'
|
6
|
+
l.style.display = 'none'
|
7
|
+
l.href = URL.createObjectURL(blob)
|
8
|
+
|
9
|
+
document.body.appendChild(l)
|
10
|
+
l.click()
|
11
|
+
document.body.removeChild(l)
|
12
|
+
}
|
13
|
+
|
14
|
+
export function fileRead(d: File) {
|
15
|
+
return new Promise((r, j) => {
|
16
|
+
let reader = new FileReader()
|
17
|
+
reader.readAsText(d, 'UTF-8')
|
18
|
+
reader.onload = function (e) {
|
19
|
+
if (e && e.target) {
|
20
|
+
r(e.target.result)
|
21
|
+
} else {
|
22
|
+
j('文件读取错误')
|
23
|
+
}
|
24
|
+
}
|
25
|
+
})
|
26
|
+
}
|