@zhangqingcq/vgce 0.1.25 → 0.1.28
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +8 -1
- package/dist/style.css +1 -1
- package/dist/vgce.js +1081 -1038
- package/dist/vgce.umd.cjs +19 -19
- package/package.json +1 -1
- package/src/components/svg-editor/index.vue +24 -2
- package/src/components/svg-editor/right-panel.vue +9 -4
- package/src/components/svg-viewer.vue +20 -3
- package/src/stores/config/index.ts +10 -1
- package/src/stores/config/types.ts +7 -0
- package/src/views/EditorS.vue +22 -21
- package/types/index.d.ts +2 -1
package/package.json
CHANGED
@@ -33,14 +33,28 @@
|
|
33
33
|
import { fileRead, fileWrite } from '@/utils/file-read-write'
|
34
34
|
import { useEditPrivateStore } from '@/stores/system'
|
35
35
|
import { setEditorLoadTime } from '@/utils'
|
36
|
+
import { onMounted } from 'vue'
|
36
37
|
|
37
38
|
setEditorLoadTime()
|
38
39
|
|
39
40
|
const emits = defineEmits(['onReturn', 'onPreview', 'onSave'])
|
40
41
|
const props = withDefaults(
|
41
|
-
defineProps<{
|
42
|
+
defineProps<{
|
43
|
+
customToolbar?: IConfig
|
44
|
+
vueComp?: Record<string, any>
|
45
|
+
data?: string
|
46
|
+
saveFile?: boolean
|
47
|
+
mqtt?: { cover: boolean; url: string; user: string; pwd: string; topics: string }
|
48
|
+
}>(),
|
42
49
|
{
|
43
|
-
saveFile: false
|
50
|
+
saveFile: false,
|
51
|
+
mqtt: () => ({
|
52
|
+
cover: false,
|
53
|
+
url: '',
|
54
|
+
user: '',
|
55
|
+
pwd: '',
|
56
|
+
topics: ''
|
57
|
+
})
|
44
58
|
}
|
45
59
|
)
|
46
60
|
const globalStore = useGlobalStore(pinia)
|
@@ -126,6 +140,14 @@
|
|
126
140
|
centerRef.value.onCanvasMouseUp()
|
127
141
|
}
|
128
142
|
|
143
|
+
onMounted(() => {
|
144
|
+
configStore.net.mqtt.useGlobalMqtt = Boolean(props.mqtt?.cover)
|
145
|
+
configStore.net.mqtt.global.url = props.mqtt?.url || ''
|
146
|
+
configStore.net.mqtt.global.user = props.mqtt?.user || ''
|
147
|
+
configStore.net.mqtt.global.pwd = props.mqtt?.pwd || ''
|
148
|
+
configStore.net.mqtt.global.topics = props.mqtt?.topics || ''
|
149
|
+
})
|
150
|
+
|
129
151
|
defineExpose({
|
130
152
|
setGraphNodeJson
|
131
153
|
})
|
@@ -173,16 +173,21 @@
|
|
173
173
|
<span style="font-weight: bold">MQTT</span>
|
174
174
|
</template>
|
175
175
|
<el-form label-width="60px" label-position="left">
|
176
|
-
<el-form-item label="
|
176
|
+
<el-form-item label="外部配置" size="small">
|
177
|
+
<el-switch v-model="configStore.net.mqtt.useGlobalMqtt" /><span style="color: #999"
|
178
|
+
>(开启后这里无需配置)</span
|
179
|
+
>
|
180
|
+
</el-form-item>
|
181
|
+
<el-form-item label="URL" size="small" v-if="!configStore.net.mqtt.useGlobalMqtt">
|
177
182
|
<el-input v-model="configStore.net.mqtt.url" placeholder="如 ws://127.0.0.1:4500" />
|
178
183
|
</el-form-item>
|
179
|
-
<el-form-item label="用户名" size="small">
|
184
|
+
<el-form-item label="用户名" size="small" v-if="!configStore.net.mqtt.useGlobalMqtt">
|
180
185
|
<el-input v-model="configStore.net.mqtt.user" placeholder="username" />
|
181
186
|
</el-form-item>
|
182
|
-
<el-form-item label="密码" size="small">
|
187
|
+
<el-form-item label="密码" size="small" v-if="!configStore.net.mqtt.useGlobalMqtt">
|
183
188
|
<el-input v-model="configStore.net.mqtt.pwd" placeholder="password" />
|
184
189
|
</el-form-item>
|
185
|
-
<el-form-item label="Topics" size="small">
|
190
|
+
<el-form-item label="Topics" size="small" v-if="!configStore.net.mqtt.useGlobalMqtt">
|
186
191
|
<el-input v-model="configStore.net.mqtt.topics" placeholder="topics" />
|
187
192
|
</el-form-item>
|
188
193
|
</el-form>
|
@@ -31,7 +31,12 @@
|
|
31
31
|
|
32
32
|
const emit = defineEmits(['onMessage', 'onEvent'])
|
33
33
|
const props = withDefaults(
|
34
|
-
defineProps<{
|
34
|
+
defineProps<{
|
35
|
+
vueComp?: Record<string, any>
|
36
|
+
data?: IDataModel
|
37
|
+
canvasDrag?: boolean
|
38
|
+
showCanvasInfo?: boolean
|
39
|
+
}>(),
|
35
40
|
{
|
36
41
|
canvasDrag: true,
|
37
42
|
showCanvasInfo: true
|
@@ -55,10 +60,17 @@
|
|
55
60
|
},
|
56
61
|
net: {
|
57
62
|
mqtt: {
|
63
|
+
useGlobalMqtt: false,
|
58
64
|
url: '',
|
59
65
|
user: '',
|
60
66
|
pwd: '',
|
61
|
-
topics: ''
|
67
|
+
topics: '',
|
68
|
+
global: {
|
69
|
+
url: '',
|
70
|
+
user: '',
|
71
|
+
pwd: '',
|
72
|
+
topics: ''
|
73
|
+
}
|
62
74
|
}
|
63
75
|
}
|
64
76
|
},
|
@@ -274,7 +286,12 @@
|
|
274
286
|
}
|
275
287
|
|
276
288
|
const connectNet = () => {
|
277
|
-
|
289
|
+
let m
|
290
|
+
if (preview_data.config.net.mqtt.useGlobalMqtt) {
|
291
|
+
m = preview_data.config.net.mqtt.global
|
292
|
+
} else {
|
293
|
+
m = preview_data.config.net.mqtt
|
294
|
+
}
|
278
295
|
if (m && m.url && m.user && m.pwd && m.topics) {
|
279
296
|
link.sub(m.url, m.user, m.pwd, m.topics, (topics: string, message: string) => {
|
280
297
|
console.log(topics)
|
@@ -28,7 +28,16 @@ export const useConfigStore = defineStore('config-store', {
|
|
28
28
|
return {
|
29
29
|
svg: s,
|
30
30
|
connection_line: t,
|
31
|
-
net: {
|
31
|
+
net: {
|
32
|
+
mqtt: {
|
33
|
+
useGlobalMqtt: false,
|
34
|
+
url: '',
|
35
|
+
user: '',
|
36
|
+
pwd: '',
|
37
|
+
topics: '',
|
38
|
+
global: { url: '', user: '', pwd: '', topics: '' }
|
39
|
+
}
|
40
|
+
}
|
32
41
|
}
|
33
42
|
},
|
34
43
|
getters: {},
|
@@ -11,9 +11,16 @@ export interface IPositionCenterSvg {
|
|
11
11
|
|
12
12
|
export interface INet {
|
13
13
|
mqtt: {
|
14
|
+
useGlobalMqtt: boolean
|
14
15
|
url: string
|
15
16
|
user: string
|
16
17
|
pwd: string
|
17
18
|
topics: string
|
19
|
+
global: {
|
20
|
+
url: string
|
21
|
+
user: string
|
22
|
+
pwd: string
|
23
|
+
topics: string
|
24
|
+
}
|
18
25
|
}
|
19
26
|
}
|
package/src/views/EditorS.vue
CHANGED
@@ -1,21 +1,22 @@
|
|
1
|
-
<script setup lang="ts">
|
2
|
-
import SvgEditor from '@/components/svg-editor/index.vue'
|
3
|
-
import { useStore } from '@/stores/main'
|
4
|
-
import type { IDataModel } from '@/components/svg-editor/types'
|
5
|
-
import Preview from './Preview.vue'
|
6
|
-
|
7
|
-
const store = useStore()
|
8
|
-
|
9
|
-
const previewShow = ref(false)
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
<
|
21
|
-
|
1
|
+
<script setup lang="ts">
|
2
|
+
import SvgEditor from '@/components/svg-editor/index.vue'
|
3
|
+
import { useStore } from '@/stores/main'
|
4
|
+
import type { IDataModel } from '@/components/svg-editor/types'
|
5
|
+
import Preview from './Preview.vue'
|
6
|
+
|
7
|
+
const store = useStore()
|
8
|
+
|
9
|
+
const previewShow = ref(false)
|
10
|
+
|
11
|
+
function previewHandle(d: IDataModel) {
|
12
|
+
store.data = d
|
13
|
+
nextTick(function () {
|
14
|
+
previewShow.value = true
|
15
|
+
})
|
16
|
+
}
|
17
|
+
</script>
|
18
|
+
|
19
|
+
<template>
|
20
|
+
<SvgEditor :data="(store.data && JSON.stringify(store.data)) || ''" saveFile @onPreview="previewHandle" />
|
21
|
+
<Preview v-if="previewShow" @back="previewShow = false" />
|
22
|
+
</template>
|
package/types/index.d.ts
CHANGED
@@ -10,9 +10,10 @@ export declare const SvgEditor: DefineComponent<{
|
|
10
10
|
customToolbar?: any[]
|
11
11
|
vueComp?: Record<string, any>
|
12
12
|
saveFile?: boolean
|
13
|
+
mqtt?: { cover: boolean; url: string; user: string; pwd: string; topics: string }
|
13
14
|
onOnPreview?: (d: Record<string, any>) => void
|
14
15
|
onOnSave?: (d: Record<string, any>) => void
|
15
|
-
onOnReturn?: () => void
|
16
|
+
onOnReturn?: (d: Record<string, any>) => void
|
16
17
|
}>
|
17
18
|
export declare const SvgViewer: DefineComponent<{
|
18
19
|
data?: Record<string, any>
|