@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.
Files changed (134) hide show
  1. package/README.md +3 -1
  2. package/dist/vgce.js +5 -12
  3. package/dist/vgce.umd.cjs +2 -2
  4. package/package.json +3 -2
  5. package/src/App.vue +11 -0
  6. package/src/assets/base.less +49 -0
  7. package/src/assets/icons/add.svg +1 -0
  8. package/src/assets/icons/delete.svg +12 -0
  9. package/src/assets/icons/export.svg +1 -0
  10. package/src/assets/icons/group.svg +13 -0
  11. package/src/assets/icons/import.svg +1 -0
  12. package/src/assets/icons/lock.svg +7 -0
  13. package/src/assets/icons/menu-fold.svg +9 -0
  14. package/src/assets/icons/menu-unfold.svg +9 -0
  15. package/src/assets/icons/preview.svg +6 -0
  16. package/src/assets/icons/redo.svg +8 -0
  17. package/src/assets/icons/return.svg +8 -0
  18. package/src/assets/icons/rotate.svg +1 -0
  19. package/src/assets/icons/save.svg +9 -0
  20. package/src/assets/icons/setting.svg +6 -0
  21. package/src/assets/icons/undo.svg +7 -0
  22. package/src/assets/icons/ungroup.svg +16 -0
  23. package/src/assets/icons/unlock.svg +7 -0
  24. package/src/assets/main.less +6 -0
  25. package/src/assets/svgs/alternator.svg +8 -0
  26. package/src/assets/svgs/bot-12.svg +1 -0
  27. package/src/assets/svgs/bot-2.svg +1 -0
  28. package/src/assets/svgs/bot-3.svg +1 -0
  29. package/src/assets/svgs/bot-7.svg +1 -0
  30. package/src/assets/svgs/bot-9.svg +94 -0
  31. package/src/assets/svgs/car.svg +1 -0
  32. package/src/assets/svgs/circuit-breaker.svg +11 -0
  33. package/src/assets/svgs/clock-a.svg +23 -0
  34. package/src/assets/svgs/common-table.svg +7 -0
  35. package/src/assets/svgs/el-button.svg +10 -0
  36. package/src/assets/svgs/el-tag.svg +13 -0
  37. package/src/assets/svgs/hospital.svg +1 -0
  38. package/src/assets/svgs/house.svg +1 -0
  39. package/src/assets/svgs/light.svg +24 -0
  40. package/src/assets/svgs/now-time.svg +9 -0
  41. package/src/assets/svgs/package.svg +1 -0
  42. package/src/assets/svgs/pie-charts.svg +10 -0
  43. package/src/assets/svgs/progress-a.svg +1 -0
  44. package/src/assets/svgs/reservoir.svg +10 -0
  45. package/src/assets/svgs/svg-text.svg +5 -0
  46. package/src/assets/svgs/switch-a.svg +5 -0
  47. package/src/assets/svgs/traction-transformer.svg +11 -0
  48. package/src/components/ace-edit/index.ts +27 -0
  49. package/src/components/config/index.ts +450 -0
  50. package/src/components/config/types.ts +25 -0
  51. package/src/components/svg-analysis/index.vue +11 -0
  52. package/src/components/svg-editor/center-panel/index.vue +867 -0
  53. package/src/components/svg-editor/center-panel/types.ts +11 -0
  54. package/src/components/svg-editor/component-tree/index.vue +33 -0
  55. package/src/components/svg-editor/connection-line/index.vue +125 -0
  56. package/src/components/svg-editor/connection-panel/index.vue +198 -0
  57. package/src/components/svg-editor/export-json/index.vue +37 -0
  58. package/src/components/svg-editor/handle-panel/index.vue +342 -0
  59. package/src/components/svg-editor/import-json/index.vue +37 -0
  60. package/src/components/svg-editor/index.vue +280 -0
  61. package/src/components/svg-editor/left-panel/index.vue +83 -0
  62. package/src/components/svg-editor/right-panel/code-edit-modal.vue +50 -0
  63. package/src/components/svg-editor/right-panel/common-animate.vue +96 -0
  64. package/src/components/svg-editor/right-panel/condition.vue +101 -0
  65. package/src/components/svg-editor/right-panel/dynamic-el-form-item.vue +97 -0
  66. package/src/components/svg-editor/right-panel/index.vue +304 -0
  67. package/src/components/svg-editor/right-panel/list.vue +86 -0
  68. package/src/components/svg-editor/top-panel/index.vue +139 -0
  69. package/src/components/svg-editor/types.ts +22 -0
  70. package/src/components/svg-viewer/index.vue +340 -0
  71. package/src/components/vue3-ruler-tool/index.vue +506 -0
  72. package/src/config/files/clock-a.vue +66 -0
  73. package/src/config/files/common-table.vue +49 -0
  74. package/src/config/files/light-a.vue +72 -0
  75. package/src/config/files/now-time.vue +53 -0
  76. package/src/config/files/pie-charts.vue +72 -0
  77. package/src/config/files/progress.vue +40 -0
  78. package/src/config/files/svg-text.vue +39 -0
  79. package/src/config/files/switch-a.vue +45 -0
  80. package/src/config/index.ts +28 -0
  81. package/src/config/svg/animation/index.ts +8 -0
  82. package/src/config/svg/animation/reservoir.ts +32 -0
  83. package/src/config/svg/custom/clock-a.ts +23 -0
  84. package/src/config/svg/custom/index.ts +11 -0
  85. package/src/config/svg/custom/light.ts +29 -0
  86. package/src/config/svg/custom/svg-text.ts +54 -0
  87. package/src/config/svg/custom/switch-a.ts +29 -0
  88. package/src/config/svg/index.ts +12 -0
  89. package/src/config/svg/stateful/circuit-breaker.ts +38 -0
  90. package/src/config/svg/stateful/index.ts +8 -0
  91. package/src/config/svg/stateless/alternator.ts +28 -0
  92. package/src/config/svg/stateless/bot-12.ts +22 -0
  93. package/src/config/svg/stateless/bot-2.ts +22 -0
  94. package/src/config/svg/stateless/bot-3.ts +22 -0
  95. package/src/config/svg/stateless/bot-7.ts +22 -0
  96. package/src/config/svg/stateless/bot-9.ts +22 -0
  97. package/src/config/svg/stateless/car.ts +22 -0
  98. package/src/config/svg/stateless/hospital.ts +22 -0
  99. package/src/config/svg/stateless/house.ts +22 -0
  100. package/src/config/svg/stateless/index.ts +30 -0
  101. package/src/config/svg/stateless/package.ts +22 -0
  102. package/src/config/svg/stateless/traction-transformer.ts +28 -0
  103. package/src/config/types.ts +126 -0
  104. package/src/config/vue/component/button.ts +57 -0
  105. package/src/config/vue/component/common-table.ts +124 -0
  106. package/src/config/vue/component/index.ts +13 -0
  107. package/src/config/vue/component/now-time.ts +29 -0
  108. package/src/config/vue/component/progress.ts +29 -0
  109. package/src/config/vue/component/tag.ts +46 -0
  110. package/src/config/vue/echarts/index.ts +8 -0
  111. package/src/config/vue/echarts/pie-charts.ts +60 -0
  112. package/src/config/vue/index.ts +5 -0
  113. package/src/hooks.ts +47 -0
  114. package/src/index.ts +14 -0
  115. package/src/main.ts +15 -0
  116. package/src/router.ts +24 -0
  117. package/src/stores/config/index.ts +44 -0
  118. package/src/stores/config/types.ts +27 -0
  119. package/src/stores/global/index.ts +109 -0
  120. package/src/stores/global/types.ts +115 -0
  121. package/src/stores/main.ts +10 -0
  122. package/src/stores/svg-edit-layout/index.ts +17 -0
  123. package/src/stores/svg-edit-layout/types.ts +8 -0
  124. package/src/stores/system/index.ts +174 -0
  125. package/src/stores/system/types.ts +43 -0
  126. package/src/utils/fetch.ts +351 -0
  127. package/src/utils/file-read-write.ts +26 -0
  128. package/src/utils/index.ts +397 -0
  129. package/src/utils/mqtt-net.ts +48 -0
  130. package/src/utils/proxy.ts +7 -0
  131. package/src/utils/scale-core.ts +214 -0
  132. package/src/utils/types.ts +13 -0
  133. package/src/views/EditorS.vue +18 -0
  134. package/src/views/Preview.vue +12 -0
@@ -0,0 +1,83 @@
1
+ <!--左侧工具栏-->
2
+ <script lang="ts" setup>
3
+ import { ref } from 'vue'
4
+ import { ElCollapse, ElCollapseItem, ElIcon, ElMessage } from 'element-plus'
5
+ import type { IConfig, IConfigItem } from '@/config/types'
6
+ import { pinia } from '@/hooks'
7
+ import { useGlobalStore } from '@/stores/global'
8
+ import SvgAnalysis from '@/components/svg-analysis/index.vue'
9
+ import { EGlobalStoreIntention } from '@/stores/global/types'
10
+ import { prosToVBind } from '@/utils'
11
+
12
+ const globalStore = useGlobalStore(pinia)
13
+ const props = defineProps<{ customToolbar: IConfig | undefined }>()
14
+ const left_tool_bar = ref(
15
+ props.customToolbar && Object.keys(props.customToolbar).length > 0 ? props.customToolbar : globalStore.config_center
16
+ )
17
+ const activeNames = ref([
18
+ 'stateful',
19
+ 'stateless',
20
+ 'have_animation',
21
+ 'custom_svg_group',
22
+ 'element-ui',
23
+ 'custom-vue',
24
+ 'echarts'
25
+ ])
26
+ const createBegin = (svg_item: IConfigItem) => {
27
+ globalStore.setCreateInfo(svg_item)
28
+ }
29
+ const dragEndEvent = (e: DragEvent) => {
30
+ //拖动时记录拖动的svg信息
31
+ if (e.dataTransfer?.dropEffect !== 'copy') {
32
+ ElMessage.warning('请将组件拖到画布中!')
33
+ //清空已选择的信息
34
+ globalStore.intention = EGlobalStoreIntention.None
35
+ return
36
+ }
37
+ }
38
+ </script>
39
+ <template>
40
+ <div>
41
+ <el-collapse v-model="activeNames">
42
+ <el-collapse-item :name="item.groupType" v-for="item of left_tool_bar" :key="item.title">
43
+ <template #title>
44
+ <div style="font-weight: bold">{{ item.title }}</div>
45
+ </template>
46
+ <div class="component-group flex flex-wrap">
47
+ <div
48
+ v-for="svg_item in item.list"
49
+ class="ideal"
50
+ :key="svg_item.name"
51
+ draggable="true"
52
+ @dragstart="createBegin(svg_item)"
53
+ @dragend="dragEndEvent"
54
+ :title="svg_item.title"
55
+ >
56
+ <el-icon :size="35" class="flex items-center">
57
+ <svg-analysis :name="svg_item.name" :props="prosToVBind(svg_item)" />
58
+ </el-icon>
59
+ </div>
60
+ </div>
61
+ </el-collapse-item>
62
+ </el-collapse>
63
+ </div>
64
+ </template>
65
+
66
+ <style scoped lang="less">
67
+ .component-group {
68
+ .ideal {
69
+ margin: 5px;
70
+ border: 1px solid transparent;
71
+ cursor: pointer;
72
+
73
+ &:hover {
74
+ border-color: #f0a0f8;
75
+ opacity: 0.85;
76
+ }
77
+
78
+ .items-center {
79
+ font-style: normal;
80
+ }
81
+ }
82
+ }
83
+ </style>
@@ -0,0 +1,50 @@
1
+ <script setup lang="ts">
2
+ import { VAceEditor } from 'vue3-ace-editor'
3
+ import '@/components/ace-edit'
4
+ import { ElButton, ElDialog } from 'element-plus'
5
+ import { computed, ref } from 'vue'
6
+
7
+ const props = withDefaults(defineProps<{ modelValue: any; lang: string; title: string }>(), {
8
+ modelValue: () => ({}),
9
+ lang: 'json',
10
+ title: '编辑'
11
+ })
12
+ const open = ref(false)
13
+ const emits = defineEmits(['update:modelValue'])
14
+
15
+ const content = computed({
16
+ get() {
17
+ if (props.lang === 'json') {
18
+ return JSON.stringify(props.modelValue, null, 2)
19
+ }
20
+ return props.modelValue
21
+ },
22
+ set(val) {
23
+ if (props.lang === 'json') {
24
+ emits('update:modelValue', JSON.parse(val))
25
+ } else {
26
+ emits('update:modelValue', val)
27
+ }
28
+ }
29
+ })
30
+ </script>
31
+
32
+ <template>
33
+ <div>
34
+ <el-button @click="open = true">···</el-button>
35
+ <el-dialog class="modal-full" v-model="open" :title="props.title" width="60%">
36
+ <v-ace-editor
37
+ v-model:value="content"
38
+ :lang="props.lang"
39
+ theme="kr_theme"
40
+ style="height: 400px"
41
+ :options="{
42
+ useWorker: true,
43
+ enableBasicAutocompletion: true,
44
+ enableSnippets: true,
45
+ enableLiveAutocompletion: true
46
+ }"
47
+ />
48
+ </el-dialog>
49
+ </div>
50
+ </template>
@@ -0,0 +1,96 @@
1
+ <script setup lang="ts">
2
+ import { ElTag, ElDrawer, ElTabs, ElTabPane, ElScrollbar, ElIcon } from 'element-plus'
3
+ import { ref, watch } from 'vue'
4
+ import { common_animate_list } from '@/components/config'
5
+ import SvgAnalysis from '@/components/svg-analysis/index.vue'
6
+
7
+ const props = defineProps<{ val: string }>()
8
+ const emits = defineEmits(['updateCommonAniVal'])
9
+ const select_val = ref(props.val)
10
+ const drawer_visible = ref(false)
11
+ const activeName = ref('进入')
12
+ const play_index = ref<null | number>(null)
13
+ const addAnimation = (val: string) => {
14
+ emits('updateCommonAniVal', val)
15
+ drawer_visible.value = false
16
+ }
17
+ watch(
18
+ () => props.val,
19
+ (new_val) => {
20
+ select_val.value = new_val
21
+ }
22
+ )
23
+ </script>
24
+
25
+ <template>
26
+ <div style="height: 100%">
27
+ <el-tag closable v-if="select_val" @close="addAnimation('')" @click="drawer_visible = true" style="cursor: pointer"
28
+ >{{
29
+ common_animate_list
30
+ .map((m) => m.children)
31
+ .reduce((pre, curr) => {
32
+ return pre.concat(curr)
33
+ })
34
+ .find((f) => f.value == select_val)?.label
35
+ }}
36
+ <el-icon :size="10">
37
+ <svg-analysis name="setting" />
38
+ </el-icon>
39
+ </el-tag>
40
+ <el-tag v-else type="success" style="cursor: pointer" @click="drawer_visible = true">新增</el-tag>
41
+ <el-drawer v-model="drawer_visible" title="选择动画" direction="ltr">
42
+ <el-tabs v-model="activeName">
43
+ <el-tab-pane
44
+ :label="tab_item.label"
45
+ :name="tab_item.label"
46
+ v-for="tab_item in common_animate_list"
47
+ :key="tab_item.label"
48
+ >
49
+ <el-scrollbar height="500px">
50
+ <div class="flex flex-wrap">
51
+ <div
52
+ class="animate"
53
+ v-for="(animate, index) in tab_item.children"
54
+ :key="index"
55
+ @mouseenter="play_index = index"
56
+ @mouseleave="play_index = null"
57
+ @click="addAnimation(animate.value)"
58
+ >
59
+ <div
60
+ :class="`${
61
+ play_index == index
62
+ ? `animate__animated animate__${animate.value} animate__slow animate__infinite`
63
+ : ''
64
+ }`"
65
+ >
66
+ {{ animate.label }}
67
+ </div>
68
+ </div>
69
+ </div>
70
+ </el-scrollbar>
71
+ </el-tab-pane>
72
+ </el-tabs>
73
+ </el-drawer>
74
+ </div>
75
+ </template>
76
+
77
+ <style scoped>
78
+ .animate {
79
+ cursor: pointer;
80
+ }
81
+
82
+ .animate > div {
83
+ width: 80px;
84
+ height: 60px;
85
+ background: #f5f8fb;
86
+ display: flex;
87
+ align-items: center;
88
+ justify-content: center;
89
+ margin: 0 12px 10px 12px;
90
+ font-size: 12px;
91
+ color: #333;
92
+ border-radius: 3px;
93
+ user-select: none;
94
+ cursor: pointer;
95
+ }
96
+ </style>
@@ -0,0 +1,101 @@
1
+ <script setup lang="ts">
2
+ import { computed } from 'vue'
3
+ import { ElFormItem, ElInput, ElOption, ElSelect } from 'element-plus/es'
4
+ import type { ICondition } from '@/config/types'
5
+ import { EConditionType } from '@/config/types'
6
+
7
+ const props = withDefaults(defineProps<{ modelValue: ICondition }>(), {
8
+ modelValue: () => ({ type: EConditionType.None })
9
+ })
10
+ const emit = defineEmits(['update:modelValue'])
11
+ const value = computed({
12
+ get() {
13
+ return props.modelValue
14
+ },
15
+ set(val) {
16
+ emit('update:modelValue', val)
17
+ }
18
+ })
19
+
20
+ const re: { label: string; val: any }[] = [
21
+ {
22
+ label: '大于',
23
+ val: 'greater'
24
+ },
25
+ {
26
+ label: '大于等于',
27
+ val: '>='
28
+ },
29
+ {
30
+ label: '小于',
31
+ val: '<'
32
+ },
33
+ {
34
+ label: '小于等于',
35
+ val: '<='
36
+ },
37
+ {
38
+ label: '等于',
39
+ val: '=='
40
+ },
41
+ {
42
+ label: '不等于',
43
+ val: '!='
44
+ },
45
+ {
46
+ label: '介于',
47
+ val: '>=,=<'
48
+ },
49
+ {
50
+ label: '不介于',
51
+ val: '<,>'
52
+ }
53
+ ]
54
+
55
+ const typeChange = (d: string) => {
56
+ if (d !== 'None') {
57
+ value.value.Relation = {
58
+ key: '',
59
+ relation: '',
60
+ val: '',
61
+ val2: ''
62
+ }
63
+ }
64
+ emit('update:modelValue', value)
65
+ }
66
+ </script>
67
+
68
+ <template>
69
+ <div class="c-wall-d">
70
+ <el-form-item label="条件" size="small">
71
+ <el-select v-model="value.type" @change="typeChange">
72
+ <el-option value="None" label="无" />
73
+ <el-option value="Relation" label="关系运算" />
74
+ </el-select>
75
+ </el-form-item>
76
+ <el-form-item label="属性" size="small" v-if="value.type === 'Relation'">
77
+ <el-input v-model="value.Relation!.key" />
78
+ </el-form-item>
79
+ <el-form-item label="关系" size="small" v-if="value.type === 'Relation'">
80
+ <el-select v-model="value.Relation!.relation">
81
+ <el-option :value="e.val" :label="e.label" v-for="(e, i) of re" :key="'rop' + i" />
82
+ </el-select>
83
+ </el-form-item>
84
+ <el-form-item label="值" size="small" v-if="value.type === 'Relation'">
85
+ <el-input v-model="value.Relation!.val" />
86
+ </el-form-item>
87
+ <el-form-item
88
+ label="值2"
89
+ size="small"
90
+ v-if="value.type === 'Relation' && (value.Relation?.relation === '>=,=<' || value.Relation?.relation === '<,>')"
91
+ >
92
+ <el-input v-model="value.Relation!.val2" />
93
+ </el-form-item>
94
+ </div>
95
+ </template>
96
+
97
+ <style lang="less" scoped>
98
+ .c-wall-d {
99
+ padding-top: 10px;
100
+ }
101
+ </style>
@@ -0,0 +1,97 @@
1
+ <script setup lang="ts">
2
+ import { EConfigItemPropsType } from '@/config/types'
3
+ import type { IConfigItemProps } from '@/config/types'
4
+ import {
5
+ ElFormItem,
6
+ ElColorPicker,
7
+ ElInputNumber,
8
+ ElInput,
9
+ ElSelect,
10
+ ElOption,
11
+ ElSwitch,
12
+ ElTooltip
13
+ } from 'element-plus'
14
+ import { getStringWidth } from '@/utils'
15
+ import CodeEditModal from '@/components/svg-editor/right-panel/code-edit-modal.vue'
16
+
17
+ const props = withDefaults(defineProps<{ objInfo?: IConfigItemProps; hide?: string[]; code?: boolean }>(), {
18
+ objInfo: () => ({}),
19
+ hide: () => [],
20
+ code: false
21
+ })
22
+ </script>
23
+
24
+ <template>
25
+ <div v-for="(attr_item, key) in props.objInfo" :key="key">
26
+ <el-form-item v-if="props.code" class="props-row" size="small">
27
+ <template #label>
28
+ <el-tooltip
29
+ :content="String(key)"
30
+ v-if="getStringWidth(String(key)) > 78"
31
+ placement="left"
32
+ popper-class="props-popper"
33
+ >
34
+ <div class="one-row-txt" style="width: 78px">{{ key }}</div>
35
+ </el-tooltip>
36
+ <span v-else>{{ key }}</span>
37
+ </template>
38
+ <el-tooltip
39
+ :content="attr_item.val"
40
+ v-if="getStringWidth(String(attr_item.val)) > 145"
41
+ placement="left"
42
+ popper-class="props-popper"
43
+ >
44
+ <div class="one-row-txt" style="width: 145px">{{ attr_item.val }}</div>
45
+ </el-tooltip>
46
+ <span v-else>{{ attr_item.val }}</span>
47
+ </el-form-item>
48
+ <el-form-item :label="attr_item.title" size="small" v-if="props.hide.indexOf(String(key)) < 0">
49
+ <el-select
50
+ v-if="attr_item.type === EConfigItemPropsType.Select"
51
+ v-model="attr_item.val"
52
+ placeholder="Select"
53
+ size="small"
54
+ :disabled="Boolean(attr_item?.disabled)"
55
+ >
56
+ <el-option v-for="item in attr_item.options" :key="item.value" :label="item.label" :value="item.value" />
57
+ </el-select>
58
+ <el-input-number
59
+ v-else-if="attr_item.type === EConfigItemPropsType.InputNumber"
60
+ v-model="attr_item.val"
61
+ :disabled="Boolean(attr_item?.disabled)"
62
+ ></el-input-number>
63
+ <el-input
64
+ v-else-if="attr_item.type === EConfigItemPropsType.Input"
65
+ v-model="attr_item.val"
66
+ :disabled="Boolean(attr_item?.disabled)"
67
+ ></el-input>
68
+ <el-color-picker
69
+ v-else-if="attr_item.type === EConfigItemPropsType.Color"
70
+ v-model="attr_item.val"
71
+ :disabled="Boolean(attr_item?.disabled)"
72
+ ></el-color-picker>
73
+ <el-switch
74
+ v-else-if="attr_item.type === EConfigItemPropsType.Switch"
75
+ v-model="attr_item.val"
76
+ :disabled="Boolean(attr_item?.disabled)"
77
+ ></el-switch>
78
+ <code-edit-modal
79
+ v-else-if="attr_item.type === EConfigItemPropsType.JsonEdit"
80
+ v-model="attr_item.val"
81
+ :disabled="Boolean(attr_item?.disabled)"
82
+ />
83
+ </el-form-item>
84
+ </div>
85
+ </template>
86
+ <style lang="less" scoped>
87
+ .one-row-txt {
88
+ white-space: nowrap;
89
+ overflow: hidden;
90
+ text-overflow: ellipsis;
91
+ }
92
+ </style>
93
+ <style lang="less">
94
+ .props-popper {
95
+ max-width: 350px;
96
+ }
97
+ </style>