@zhangqingcq/vgce 0.0.31 → 0.0.32
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/style.css +2 -2
- package/dist/vgce.js +6888 -6818
- package/dist/vgce.umd.cjs +64 -64
- package/package.json +1 -1
- package/src/assets/base.less +23 -6
- package/src/assets/variables.less +8 -0
- package/src/components/svg-editor/center-panel.vue +19 -22
- package/src/components/svg-editor/component-tree.vue +3 -2
- package/src/components/svg-editor/connection-line.vue +40 -4
- package/src/components/svg-editor/connection-panel.vue +24 -0
- package/src/components/svg-editor/index.vue +9 -3
- package/src/components/svg-editor/top-panel.vue +5 -3
- package/src/components/svg-viewer.vue +17 -31
- package/src/components/vue3-ruler-tool.vue +10 -0
- package/src/utils/index.ts +14 -1
package/package.json
CHANGED
package/src/assets/base.less
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
@import '@/assets/variables';
|
2
|
+
|
1
3
|
*,
|
2
4
|
*::before,
|
3
5
|
*::after {
|
@@ -44,15 +46,15 @@ body {
|
|
44
46
|
}
|
45
47
|
|
46
48
|
.icon-out {
|
47
|
-
fill:
|
49
|
+
fill: @iconOutColor;
|
48
50
|
}
|
49
51
|
|
50
52
|
.icon-in {
|
51
|
-
fill:
|
53
|
+
fill: @iconInColor;
|
52
54
|
}
|
53
55
|
|
54
56
|
.icon-middle {
|
55
|
-
fill:
|
57
|
+
fill: @iconMiddleColor;
|
56
58
|
}
|
57
59
|
|
58
60
|
.gray{
|
@@ -71,15 +73,15 @@ body {
|
|
71
73
|
|
72
74
|
.active{
|
73
75
|
.icon-out {
|
74
|
-
fill:
|
76
|
+
fill: @activeIconOut;
|
75
77
|
}
|
76
78
|
|
77
79
|
.icon-in {
|
78
|
-
fill:
|
80
|
+
fill: @activeIconIn;
|
79
81
|
}
|
80
82
|
|
81
83
|
.icon-middle {
|
82
|
-
fill:
|
84
|
+
fill: @activeIconMiddle;
|
83
85
|
}
|
84
86
|
}
|
85
87
|
|
@@ -95,3 +97,18 @@ body {
|
|
95
97
|
color: #aaa;
|
96
98
|
}
|
97
99
|
}
|
100
|
+
|
101
|
+
.foreignObject {
|
102
|
+
> span {
|
103
|
+
/*解决span标签显示不完整的问题*/
|
104
|
+
position: relative;
|
105
|
+
bottom: 2px;
|
106
|
+
}
|
107
|
+
}
|
108
|
+
|
109
|
+
.tree-v {
|
110
|
+
--el-color-primary-light-9: @listActiveColor;
|
111
|
+
&.el-tree--highlight-current .el-tree-node.is-current>.el-tree-node__content{
|
112
|
+
color: #fff;
|
113
|
+
}
|
114
|
+
}
|
@@ -6,6 +6,7 @@
|
|
6
6
|
import { EGlobalStoreIntention, EMouseInfoState, EScaleInfoType } from '@/stores/global/types'
|
7
7
|
import { useSvgEditLayoutStore } from '@/stores/svg-edit-layout'
|
8
8
|
import {
|
9
|
+
componentsRegister,
|
9
10
|
createLine,
|
10
11
|
getCenterPoint,
|
11
12
|
getCommonClass,
|
@@ -35,24 +36,17 @@
|
|
35
36
|
import { EDoneJsonType } from '@/config/types'
|
36
37
|
import ConnectionLine from '@/components/svg-editor/connection-line.vue'
|
37
38
|
import type { IVisibleInfo } from '../config'
|
38
|
-
import { vueComp } from '@/config'
|
39
39
|
import { useContextMenuStore, useEditPrivateStore } from '@/stores/system'
|
40
40
|
import { EContextMenuInfoType } from '@/stores/system/types'
|
41
|
-
import
|
41
|
+
import ImportJson from '@/components/svg-editor/import-json.vue'
|
42
42
|
|
43
|
-
//注册所有组件
|
44
|
-
const instance = getCurrentInstance()
|
45
|
-
Object.keys(vueComp).forEach((key) => {
|
46
|
-
if (!Object.keys(instance?.appContext?.components as any).includes(key)) {
|
47
|
-
// @ts-ignore
|
48
|
-
instance?.appContext.app.component(key, vueComp[key])
|
49
|
-
}
|
50
|
-
})
|
51
43
|
const globalStore = useGlobalStore(pinia)
|
52
44
|
const configStore = useConfigStore(pinia)
|
53
45
|
const svgEditLayoutStore = useSvgEditLayoutStore(pinia)
|
54
46
|
const editPrivateStore = useEditPrivateStore(pinia)
|
55
47
|
const contextMenuStore = useContextMenuStore(pinia)
|
48
|
+
|
49
|
+
componentsRegister()
|
56
50
|
const contextMenuRef = ref<HTMLElement>()
|
57
51
|
const canvasRef = ref<HTMLElement>()
|
58
52
|
const ct: Record<string, any> = {
|
@@ -210,17 +204,19 @@
|
|
210
204
|
const onSvgMouseDown = (select_item: IDoneJson, index: number, e: MouseEvent) => {
|
211
205
|
canvasRef.value?.focus()
|
212
206
|
if (globalStore.intention === EGlobalStoreIntention.Connection) {
|
207
|
+
e.stopPropagation()
|
213
208
|
return
|
214
209
|
}
|
215
210
|
e.preventDefault()
|
216
211
|
e.stopPropagation()
|
217
212
|
if (e.ctrlKey && e.button === 0) {
|
218
213
|
//ctrl+鼠标左键 多选组件
|
219
|
-
if (globalStore.handle_svg_info?.index) {
|
214
|
+
if (globalStore.handle_svg_info?.index || globalStore.handle_svg_info?.index === 0) {
|
220
215
|
globalStore.done_json[globalStore.handle_svg_info.index].selected = true
|
221
216
|
globalStore.setHandleSvgInfo(null)
|
222
|
-
|
217
|
+
globalStore.intention = EGlobalStoreIntention.None
|
223
218
|
}
|
219
|
+
select_item.selected = !select_item.selected
|
224
220
|
} else if (isGroup.value) {
|
225
221
|
//有框选的组件
|
226
222
|
globalStore.intention = EGlobalStoreIntention.GroupMove
|
@@ -941,6 +937,8 @@
|
|
941
937
|
}
|
942
938
|
})
|
943
939
|
})
|
940
|
+
|
941
|
+
defineExpose({ onCanvasMouseUp })
|
944
942
|
</script>
|
945
943
|
|
946
944
|
<template>
|
@@ -1087,7 +1085,11 @@
|
|
1087
1085
|
/>
|
1088
1086
|
|
1089
1087
|
<handle-panel
|
1090
|
-
v-if="
|
1088
|
+
v-if="
|
1089
|
+
globalStore.handle_svg_info?.info.id === item.id &&
|
1090
|
+
visible_info.handle_panel &&
|
1091
|
+
item.type !== EDoneJsonType.ConnectionLine
|
1092
|
+
"
|
1091
1093
|
:item-info="item"
|
1092
1094
|
/>
|
1093
1095
|
<connection-panel
|
@@ -1136,6 +1138,8 @@
|
|
1136
1138
|
</template>
|
1137
1139
|
|
1138
1140
|
<style lang="less" scoped>
|
1141
|
+
@import '@/assets/variables';
|
1142
|
+
|
1139
1143
|
.canvas {
|
1140
1144
|
width: 100%;
|
1141
1145
|
height: 100%;
|
@@ -1168,14 +1172,6 @@
|
|
1168
1172
|
outline: 1px solid rgb(222, 69, 23);
|
1169
1173
|
}
|
1170
1174
|
|
1171
|
-
.foreignObject {
|
1172
|
-
> span {
|
1173
|
-
/*解决span标签显示不完整的问题*/
|
1174
|
-
position: relative;
|
1175
|
-
bottom: 2px;
|
1176
|
-
}
|
1177
|
-
}
|
1178
|
-
|
1179
1175
|
.contextMenu {
|
1180
1176
|
position: fixed;
|
1181
1177
|
z-index: 99999;
|
@@ -1208,7 +1204,7 @@
|
|
1208
1204
|
}
|
1209
1205
|
|
1210
1206
|
p:hover {
|
1211
|
-
background-color:
|
1207
|
+
background-color: @listActiveColor;
|
1212
1208
|
color: #ffffff;
|
1213
1209
|
cursor: default;
|
1214
1210
|
}
|
@@ -1220,6 +1216,7 @@
|
|
1220
1216
|
.disabled:hover {
|
1221
1217
|
color: #999;
|
1222
1218
|
background-color: transparent;
|
1219
|
+
cursor: not-allowed;
|
1223
1220
|
}
|
1224
1221
|
|
1225
1222
|
li.separator {
|
@@ -6,7 +6,7 @@
|
|
6
6
|
import type { IDoneJson } from '@/stores/global/types'
|
7
7
|
|
8
8
|
const global_store = useGlobalStore(pinia)
|
9
|
-
const current_node_key =
|
9
|
+
const current_node_key = computed(() => global_store.handle_svg_info?.info.id ?? '')
|
10
10
|
const handleNodeClick = (data: IDoneJson) => {
|
11
11
|
for (let e of global_store.done_json) {
|
12
12
|
e.selected = false
|
@@ -24,12 +24,13 @@
|
|
24
24
|
|
25
25
|
<template>
|
26
26
|
<el-tree
|
27
|
+
class="tree-v"
|
27
28
|
:data="global_store.done_json"
|
28
29
|
:props="defaultProps"
|
29
30
|
@node-click="handleNodeClick"
|
30
31
|
:default-expand-all="true"
|
31
32
|
:expand-on-click-node="false"
|
32
|
-
:highlight-current="
|
33
|
+
:highlight-current="Boolean(current_node_key)"
|
33
34
|
node-key="id"
|
34
35
|
:current-node-key="current_node_key"
|
35
36
|
/>
|
@@ -40,7 +40,29 @@
|
|
40
40
|
</script>
|
41
41
|
|
42
42
|
<template>
|
43
|
-
<g>
|
43
|
+
<g :style="{ cursor: globalStore.intention === EGlobalStoreIntention.Connection ? 'crosshair' : 'move' }">
|
44
|
+
<!-- 选中效果 -->
|
45
|
+
<path
|
46
|
+
:d="positionArrToPath(props.itemInfo.props.point_position.val)"
|
47
|
+
fill="none"
|
48
|
+
fill-opacity="0"
|
49
|
+
stroke="#DE4517"
|
50
|
+
:stroke-width="props.itemInfo.props['stroke-width'].val + 1"
|
51
|
+
stroke-linecap="round"
|
52
|
+
stroke-linejoin="round"
|
53
|
+
v-show="props.itemInfo.selected || props.itemInfo.id === globalStore.handle_svg_info?.info.id"
|
54
|
+
/>
|
55
|
+
<!-- 打底 -->
|
56
|
+
<path
|
57
|
+
:d="positionArrToPath(props.itemInfo.props.point_position.val)"
|
58
|
+
fill="none"
|
59
|
+
fill-opacity="0"
|
60
|
+
stroke="#fff"
|
61
|
+
stroke-opacity=".01"
|
62
|
+
:stroke-width="props.itemInfo.props['stroke-width'].val"
|
63
|
+
stroke-linecap="round"
|
64
|
+
stroke-linejoin="round"
|
65
|
+
/>
|
44
66
|
<path
|
45
67
|
:id="props.itemInfo.id"
|
46
68
|
:d="positionArrToPath(props.itemInfo.props.point_position.val)"
|
@@ -51,13 +73,13 @@
|
|
51
73
|
: props.itemInfo.props.stroke.val
|
52
74
|
"
|
53
75
|
:stroke-width="props.itemInfo.props['stroke-width'].val"
|
54
|
-
:style="{ cursor: globalStore.intention === EGlobalStoreIntention.Connection ? 'crosshair' : 'move' }"
|
55
76
|
stroke-dashoffset="0"
|
56
77
|
:stroke-dasharray="
|
57
78
|
props.itemInfo.animations?.type.val === EConfigAnimationsType.Electricity
|
58
79
|
? props.itemInfo.props['stroke-width'].val * 3
|
59
80
|
: 0
|
60
81
|
"
|
82
|
+
stroke-linejoin="round"
|
61
83
|
>
|
62
84
|
<animate
|
63
85
|
v-if="props.itemInfo.animations?.type.val === EConfigAnimationsType.Electricity"
|
@@ -79,6 +101,7 @@
|
|
79
101
|
:stroke-dasharray="props.itemInfo.props['stroke-width'].val * 3"
|
80
102
|
stroke-dashoffset="0"
|
81
103
|
stroke-linecap="round"
|
104
|
+
stroke-linejoin="round"
|
82
105
|
>
|
83
106
|
<animate
|
84
107
|
attributeName="stroke-dashoffset"
|
@@ -94,7 +117,7 @@
|
|
94
117
|
v-else-if="props.itemInfo.animations?.type.val === EConfigAnimationsType.Track"
|
95
118
|
cx="0"
|
96
119
|
cy="0"
|
97
|
-
:r="props.itemInfo.props['stroke-width'].val * 2"
|
120
|
+
:r="Math.ceil(props.itemInfo.props['stroke-width'].val * 0.6) + 2"
|
98
121
|
:fill="props.itemInfo.animations.color.val"
|
99
122
|
>
|
100
123
|
<animateMotion
|
@@ -110,8 +133,21 @@
|
|
110
133
|
>
|
111
134
|
</animateMotion>
|
112
135
|
</circle>
|
113
|
-
<!-- 更改线段 -->
|
114
136
|
<g>
|
137
|
+
<!-- 节点选中效果 -->
|
138
|
+
<circle
|
139
|
+
v-for="(item, index) in props.itemInfo.props.point_position.val"
|
140
|
+
:key="index"
|
141
|
+
:cx="item.x"
|
142
|
+
:cy="item.y"
|
143
|
+
:r="props.itemInfo.props.point_r.val + 1"
|
144
|
+
fill="none"
|
145
|
+
fill-opacity="0"
|
146
|
+
stroke-width="1"
|
147
|
+
stroke="#DE4517"
|
148
|
+
v-show="props.itemInfo.selected || props.itemInfo.id === globalStore.handle_svg_info?.info.id"
|
149
|
+
/>
|
150
|
+
<!-- 更改线段 -->
|
115
151
|
<circle
|
116
152
|
v-for="(item, index) in props.itemInfo.props.point_position.val"
|
117
153
|
:key="index"
|
@@ -6,6 +6,7 @@
|
|
6
6
|
import { createLine, getCoordinateOffset, moveAnchors } from '@/utils'
|
7
7
|
import { useGlobalStore } from '@/stores/global'
|
8
8
|
import { pinia } from '@/hooks'
|
9
|
+
import { useSvgEditLayoutStore } from '@/stores/svg-edit-layout'
|
9
10
|
|
10
11
|
const props = defineProps<{
|
11
12
|
itemInfo: IDoneJson
|
@@ -15,6 +16,7 @@
|
|
15
16
|
const radius = ref(4)
|
16
17
|
const outRadius = ref(12)
|
17
18
|
const globalStore = useGlobalStore(pinia)
|
19
|
+
const svgEditLayoutStore = useSvgEditLayoutStore(pinia)
|
18
20
|
|
19
21
|
const cxT = computed(
|
20
22
|
() => props.itemInfo.actual_bound.x + props.itemInfo.actual_bound.width / 2 - offset.value + radius.value
|
@@ -105,6 +107,28 @@
|
|
105
107
|
const bindAnchor = (e: any, type: ELineBindAnchors) => {
|
106
108
|
if (globalStore.intention === EGlobalStoreIntention.None) {
|
107
109
|
createLine(e, type, props.itemInfo)
|
110
|
+
if (globalStore.handle_svg_info) {
|
111
|
+
//鼠标左键创建新线段
|
112
|
+
if (globalStore.handle_svg_info.info.props.point_position.val.length !== 1) {
|
113
|
+
//鼠标移动后的实时位置(相对于起始点,只在创建第一个点时记录了鼠标原始位置)
|
114
|
+
globalStore.handle_svg_info.info.props.point_position.val.push({
|
115
|
+
x:
|
116
|
+
globalStore.mouse_info.new_position_x -
|
117
|
+
globalStore.mouse_info.position_x -
|
118
|
+
svgEditLayoutStore.center_offset.x,
|
119
|
+
y:
|
120
|
+
globalStore.mouse_info.new_position_y -
|
121
|
+
globalStore.mouse_info.position_y -
|
122
|
+
svgEditLayoutStore.center_offset.y
|
123
|
+
})
|
124
|
+
} else {
|
125
|
+
//第二个点,在鼠标没有移动的情况下,就是起始点
|
126
|
+
globalStore.handle_svg_info.info.props.point_position.val.push({
|
127
|
+
x: 0,
|
128
|
+
y: 0
|
129
|
+
})
|
130
|
+
}
|
131
|
+
}
|
108
132
|
} else if (globalStore.intention === EGlobalStoreIntention.Connection) {
|
109
133
|
//在连线的情况下,点击锚点,结束连线并绑定锚点
|
110
134
|
e.stopPropagation()
|
@@ -34,6 +34,7 @@
|
|
34
34
|
import { useEditPrivateStore } from '@/stores/system'
|
35
35
|
|
36
36
|
//todo 优化自带组件使用体验
|
37
|
+
const emits = defineEmits(['onReturn', 'onPreview', 'onSave'])
|
37
38
|
const props = withDefaults(defineProps<{ customToolbar?: IConfig; data?: string; saveFile?: boolean }>(), {
|
38
39
|
saveFile: false
|
39
40
|
})
|
@@ -41,13 +42,14 @@
|
|
41
42
|
const svgEditLayoutStore = useSvgEditLayoutStore(pinia)
|
42
43
|
const configStore = useConfigStore(pinia)
|
43
44
|
const editPrivateStore = useEditPrivateStore(pinia)
|
45
|
+
|
46
|
+
const centerRef = ref()
|
44
47
|
const importJsonRef = ref<InstanceType<typeof ImportJson>>()
|
45
48
|
const visible_conf: IVisibleConf = reactive({
|
46
49
|
[EVisibleConfKey.ExportJson]: false,
|
47
50
|
[EVisibleConfKey.ImportJson]: false,
|
48
51
|
[EVisibleConfKey.ImportFile]: false
|
49
52
|
})
|
50
|
-
const emits = defineEmits(['onReturn', 'onPreview', 'onSave'])
|
51
53
|
const changeVisible = (key: EVisibleConfKey, val: boolean) => {
|
52
54
|
visible_conf[key] = val
|
53
55
|
}
|
@@ -116,6 +118,10 @@
|
|
116
118
|
}
|
117
119
|
}
|
118
120
|
|
121
|
+
function onLineMouseUp() {
|
122
|
+
centerRef.value.onCanvasMouseUp()
|
123
|
+
}
|
124
|
+
|
119
125
|
defineExpose({
|
120
126
|
setGraphNodeJson
|
121
127
|
})
|
@@ -143,8 +149,8 @@
|
|
143
149
|
</el-aside>
|
144
150
|
<el-main class="middle main">
|
145
151
|
<div class="canvas-main-pc">
|
146
|
-
<Vue3RulerTool class="canvas-main-pc" :visible="configStore.svg.ruler">
|
147
|
-
<center-panel />
|
152
|
+
<Vue3RulerTool class="canvas-main-pc" :visible="configStore.svg.ruler" @onLineMouseUp="onLineMouseUp">
|
153
|
+
<center-panel ref="centerRef" />
|
148
154
|
</Vue3RulerTool>
|
149
155
|
</div>
|
150
156
|
</el-main>
|
@@ -156,13 +156,15 @@
|
|
156
156
|
<el-dialog v-model="open" title="使用说明" width="60%" class="guide-dialog">
|
157
157
|
<el-scrollbar max-height="60vh">
|
158
158
|
<div class="font-bold mb-10px text-15px guide-title" style="padding-top: 16px">多选</div>
|
159
|
-
<div
|
159
|
+
<div
|
160
|
+
>在画布空白区域按住鼠标左键可以框选(图形坐标在框选区域即判定被选中),也可以按住ctrl+鼠标左键点图形进行多选</div
|
161
|
+
>
|
160
162
|
<div class="el-divider el-divider--horizontal" role="separator" style="--el-border-style: solid"></div>
|
161
163
|
<div class="font-bold mb-10px text-15px guide-title">拖动画布</div>
|
162
|
-
<div
|
164
|
+
<div>在画布空白区域按住右键可拖动画布,右侧面板‘图纸’栏可微调或重置位置</div>
|
163
165
|
<div class="el-divider el-divider--horizontal" role="separator" style="--el-border-style: solid"></div>
|
164
166
|
<div class="font-bold mb-10px text-15px guide-title">画布缩放</div>
|
165
|
-
<div
|
167
|
+
<div>在画布空白区使用鼠标滚轮或者右侧面板‘图纸’栏可控制画布缩放</div>
|
166
168
|
<div class="el-divider el-divider--horizontal" role="separator" style="--el-border-style: solid"></div>
|
167
169
|
<div class="font-bold mb-10px text-15px guide-title">标尺辅助线</div>
|
168
170
|
<div>在标尺区域按住鼠标左键并拖动即可创建标尺辅助线,将标尺辅助线拖动到标尺区域即可删除标尺辅助线</div>
|
@@ -3,12 +3,19 @@
|
|
3
3
|
import { useGlobalStore } from '@/stores/global'
|
4
4
|
import { EGlobalStoreIntention, EMouseInfoState } from '@/stores/global/types'
|
5
5
|
import type { IDoneJson } from '@/stores/global/types'
|
6
|
-
import {
|
6
|
+
import {
|
7
|
+
componentsRegister,
|
8
|
+
getCommonClass,
|
9
|
+
preventDefault,
|
10
|
+
prosToVBind,
|
11
|
+
setArrItemByID,
|
12
|
+
stopEvent,
|
13
|
+
valFormat
|
14
|
+
} from '@/utils'
|
7
15
|
|
8
16
|
import { EDoneJsonType, EEventAction, EEventType } from '@/config/types'
|
9
17
|
import ConnectionLine from '@/components/svg-editor/connection-line.vue'
|
10
18
|
|
11
|
-
import { vueComp } from '@/config'
|
12
19
|
import type { IDataModel } from '@/components/svg-editor/types'
|
13
20
|
import 'element-plus/dist/index.css'
|
14
21
|
import 'animate.css'
|
@@ -16,16 +23,11 @@
|
|
16
23
|
import { sub, close } from '@/utils/mqtt-net'
|
17
24
|
|
18
25
|
const emit = defineEmits(['onMessage'])
|
19
|
-
//注册所有组件
|
20
|
-
const instance = getCurrentInstance()
|
21
|
-
Object.keys(vueComp).forEach((key: string) => {
|
22
|
-
if (!Object.keys(instance?.appContext?.components as any).includes(key)) {
|
23
|
-
instance?.appContext.app.component(key, vueComp[key])
|
24
|
-
}
|
25
|
-
})
|
26
26
|
const props = withDefaults(defineProps<{ data?: IDataModel; canvasDrag?: boolean }>(), {
|
27
27
|
canvasDrag: true
|
28
28
|
})
|
29
|
+
const globalStore = useGlobalStore(pinia)
|
30
|
+
componentsRegister()
|
29
31
|
const preview_data = reactive(
|
30
32
|
props.data ?? {
|
31
33
|
layout_center: {
|
@@ -50,7 +52,6 @@
|
|
50
52
|
done_json: []
|
51
53
|
}
|
52
54
|
)
|
53
|
-
const globalStore = useGlobalStore(pinia)
|
54
55
|
|
55
56
|
const cursor_style = computed(() => (globalStore.intention == EGlobalStoreIntention.MoveCanvas ? 'grab' : 'default'))
|
56
57
|
const onCanvasMouseMove = (e: MouseEvent) => {
|
@@ -135,9 +136,6 @@
|
|
135
136
|
height: actual_bound.height * scale_y
|
136
137
|
}
|
137
138
|
}
|
138
|
-
const setNodeAttrByID = (id: string, attr: string, val: any) => {
|
139
|
-
return setArrItemByID(id, attr, val, preview_data.done_json)
|
140
|
-
}
|
141
139
|
|
142
140
|
const getStyle = (root: IDoneJson) => {
|
143
141
|
let t = false
|
@@ -241,6 +239,10 @@
|
|
241
239
|
}
|
242
240
|
}
|
243
241
|
|
242
|
+
const setNodeAttrByID = (id: string, attr: string, val: any) => {
|
243
|
+
return setArrItemByID(id, attr, val, preview_data.done_json)
|
244
|
+
}
|
245
|
+
|
244
246
|
onMounted(() => {
|
245
247
|
connectNet()
|
246
248
|
})
|
@@ -259,6 +261,7 @@
|
|
259
261
|
@mousemove="onCanvasMouseMove"
|
260
262
|
@mouseup="onCanvasMouseUp"
|
261
263
|
@mousewheel="onMousewheel"
|
264
|
+
@contextmenu="preventDefault"
|
262
265
|
>
|
263
266
|
<svg
|
264
267
|
xmlns="http://www.w3.org/2000/svg"
|
@@ -326,6 +329,7 @@
|
|
326
329
|
v-else-if="item.type === EDoneJsonType.Vue"
|
327
330
|
v-bind="getActualBoundScale(item.actual_bound, item.scale_x, item.scale_y)"
|
328
331
|
:id="`foreign-object${item.id}`"
|
332
|
+
class="foreignObject"
|
329
333
|
>
|
330
334
|
<component
|
331
335
|
:is="item.tag"
|
@@ -356,24 +360,6 @@
|
|
356
360
|
cursor: v-bind('cursor_style');
|
357
361
|
}
|
358
362
|
|
359
|
-
.svg-item-none {
|
360
|
-
cursor: move;
|
361
|
-
|
362
|
-
&:hover {
|
363
|
-
outline: 1px solid #f8d032;
|
364
|
-
}
|
365
|
-
}
|
366
|
-
|
367
|
-
.svg-item-move {
|
368
|
-
cursor: move;
|
369
|
-
outline: 1px dashed rgb(149, 23, 222);
|
370
|
-
}
|
371
|
-
|
372
|
-
.svg-item-select {
|
373
|
-
cursor: move;
|
374
|
-
outline: 1px solid rgb(149, 23, 222);
|
375
|
-
}
|
376
|
-
|
377
363
|
.common-ani {
|
378
364
|
transform-box: fill-box;
|
379
365
|
}
|
@@ -2,7 +2,9 @@
|
|
2
2
|
import { pinia } from '@/hooks'
|
3
3
|
import { useSvgEditLayoutStore } from '@/stores/svg-edit-layout'
|
4
4
|
import { useConfigStore } from '@/stores/config'
|
5
|
+
import { preventDefault, stopEvent } from '@/utils'
|
5
6
|
|
7
|
+
const emit = defineEmits(['onLineMouseUp'])
|
6
8
|
const props = withDefaults(
|
7
9
|
defineProps<{
|
8
10
|
visible?: boolean
|
@@ -291,6 +293,10 @@
|
|
291
293
|
dragFlag = 'v'
|
292
294
|
dragLineId = id
|
293
295
|
}
|
296
|
+
|
297
|
+
const lineMouseUp = () => {
|
298
|
+
emit('onLineMouseUp')
|
299
|
+
}
|
294
300
|
</script>
|
295
301
|
|
296
302
|
<template>
|
@@ -317,6 +323,8 @@
|
|
317
323
|
:key="item.id"
|
318
324
|
:class="`vue-ruler-ref-line-${item.type}`"
|
319
325
|
@mousedown="handleDragLine(item)"
|
326
|
+
@mouseup="lineMouseUp"
|
327
|
+
@contextmenu="preventDefault"
|
320
328
|
/>
|
321
329
|
</section>
|
322
330
|
<div ref="content" class="vue-ruler-content" :style="contentStyle">
|
@@ -427,6 +435,7 @@
|
|
427
435
|
height: 4px;
|
428
436
|
cursor: n-resize;
|
429
437
|
border-top: 1px dashed #999;
|
438
|
+
|
430
439
|
span {
|
431
440
|
left: 30px;
|
432
441
|
top: 3px;
|
@@ -439,6 +448,7 @@
|
|
439
448
|
_height: 9999px;
|
440
449
|
cursor: w-resize;
|
441
450
|
border-left: 1px dashed #999;
|
451
|
+
|
442
452
|
span {
|
443
453
|
top: 30px;
|
444
454
|
left: 7px;
|
package/src/utils/index.ts
CHANGED
@@ -4,16 +4,29 @@ import type { IConfigItem } from '@/config/types'
|
|
4
4
|
import { EDoneJsonType } from '@/config/types'
|
5
5
|
import type { IDoneJson, IPointCoordinate } from '@/stores/global/types'
|
6
6
|
import { EGlobalStoreIntention, EMouseInfoState } from '@/stores/global/types'
|
7
|
-
import { straight_line_system } from '@/components/config'
|
8
7
|
import { useGlobalStore } from '@/stores/global'
|
9
8
|
import { pinia } from '@/hooks'
|
10
9
|
import { useConfigStore } from '@/stores/config'
|
11
10
|
import { useSvgEditLayoutStore } from '@/stores/svg-edit-layout'
|
12
11
|
import { kebabCase } from 'lodash-es'
|
12
|
+
import { vueComp } from '@/config'
|
13
13
|
|
14
14
|
export const stopEvent = (e: any) => {
|
15
15
|
e.stopPropagation()
|
16
16
|
}
|
17
|
+
export const preventDefault = (e: any) => {
|
18
|
+
e.preventDefault()
|
19
|
+
}
|
20
|
+
|
21
|
+
export function componentsRegister() {
|
22
|
+
//注册所有组件
|
23
|
+
const instance = getCurrentInstance()
|
24
|
+
for (let key in vueComp) {
|
25
|
+
if (!instance?.appContext?.components.hasOwnProperty(key) && vueComp.hasOwnProperty(key)) {
|
26
|
+
instance?.appContext?.app.component(key, vueComp[key])
|
27
|
+
}
|
28
|
+
}
|
29
|
+
}
|
17
30
|
|
18
31
|
/**
|
19
32
|
* 生成随机字符串
|