zydx-plus 1.33.430 → 1.33.432

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/package.json +1 -1
  2. package/src/components/biz_header/src/button_name.js +10 -10
  3. package/src/components/editor2/src/editor.vue +19 -3
  4. package/src/components/paint/index.js +6 -0
  5. package/src/components/paint/src/img/ban.png +0 -0
  6. package/src/components/paint/src/img/bi.png +0 -0
  7. package/src/components/paint/src/img/case.png +0 -0
  8. package/src/components/paint/src/img/case1.png +0 -0
  9. package/src/components/paint/src/img/case2.png +0 -0
  10. package/src/components/paint/src/img/case3.png +0 -0
  11. package/src/components/paint/src/img/fabhui.png +0 -0
  12. package/src/components/paint/src/img/fang.png +0 -0
  13. package/src/components/paint/src/img/gongsi.png +0 -0
  14. package/src/components/paint/src/img/handwriting.png +0 -0
  15. package/src/components/paint/src/img/huaban.png +0 -0
  16. package/src/components/paint/src/img/lines.png +0 -0
  17. package/src/components/paint/src/img/lingxing.png +0 -0
  18. package/src/components/paint/src/img/liubian.png +0 -0
  19. package/src/components/paint/src/img/qingchu.png +0 -0
  20. package/src/components/paint/src/img/quan.png +0 -0
  21. package/src/components/paint/src/img/sanjiao.png +0 -0
  22. package/src/components/paint/src/img/shanchu.png +0 -0
  23. package/src/components/paint/src/img/tixing.png +0 -0
  24. package/src/components/paint/src/img/tuan.png +0 -0
  25. package/src/components/paint/src/img/tuxing.png +0 -0
  26. package/src/components/paint/src/img/virtual.png +0 -0
  27. package/src/components/paint/src/img/virtualRound.png +0 -0
  28. package/src/components/paint/src/img/wenzi.png +0 -0
  29. package/src/components/paint/src/img/wu.png +0 -0
  30. package/src/components/paint/src/img/wujiao.png +0 -0
  31. package/src/components/paint/src/img/you.png +0 -0
  32. package/src/components/paint/src/img/yuan.png +0 -0
  33. package/src/components/paint/src/img/yunduo.png +0 -0
  34. package/src/components/paint/src/img/zhong.png +0 -0
  35. package/src/components/paint/src/img/zuo.png +0 -0
  36. package/src/components/paint/src/paint.vue +787 -0
  37. package/src/components/sketchpad/src/sketchpad.vue +43 -2
  38. package/src/index.js +1 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zydx-plus",
3
- "version": "1.33.430",
3
+ "version": "1.33.432",
4
4
  "description": "Vue.js",
5
5
  "main": "src/index.js",
6
6
  "files": [
@@ -2573,7 +2573,7 @@ let buttonNames = {
2573
2573
  headLevel: {
2574
2574
  default: "demand",
2575
2575
  demand: '讨论要求',
2576
- resourceIndex: '讨论任务',
2576
+ resourceIndex: '讨论题目',
2577
2577
  review: '讨论点评',
2578
2578
  analyse: '讨论分析',
2579
2579
  countermeasure: this.getJobType() === 'resource_guidance' ? '指导对策' : '教学对策',
@@ -2583,13 +2583,13 @@ let buttonNames = {
2583
2583
  },
2584
2584
  otherLevel: {
2585
2585
  default: "singletonClass",
2586
- singletonClass: this.getCurrentPrefix(item) + '任务',
2587
- allClass: this.getPrefix(item) + '任务'
2586
+ singletonClass: this.getCurrentPrefix(item) + '题目',
2587
+ allClass: this.getPrefix(item) + '题目'
2588
2588
  },
2589
2589
  lowLevel: {
2590
2590
  default: "viewResource",
2591
- createResource: '创建任务',
2592
- viewResource: '任务列表',
2591
+ createResource: '创建题目',
2592
+ viewResource: '题目列表',
2593
2593
  // selectResource: '查找资源',
2594
2594
  }
2595
2595
  }
@@ -2602,7 +2602,7 @@ let buttonNames = {
2602
2602
  headLevel: {
2603
2603
  default: "demand",
2604
2604
  demand: '风暴要求',
2605
- resourceIndex: '风暴任务',
2605
+ resourceIndex: '风暴题目',
2606
2606
  review: '风暴点评',
2607
2607
  analyse: '风暴分析',
2608
2608
  countermeasure: this.getJobType() === 'resource_guidance' ? '指导对策' : '教学对策',
@@ -2612,13 +2612,13 @@ let buttonNames = {
2612
2612
  },
2613
2613
  otherLevel: {
2614
2614
  default: "singletonClass",
2615
- singletonClass: this.getCurrentPrefix(item) + '任务',
2616
- allClass: this.getPrefix(item) + '任务'
2615
+ singletonClass: this.getCurrentPrefix(item) + '题目',
2616
+ allClass: this.getPrefix(item) + '题目'
2617
2617
  },
2618
2618
  lowLevel: {
2619
2619
  default: "viewResource",
2620
- createResource: '创建任务',
2621
- viewResource: '任务列表',
2620
+ createResource: '创建题目',
2621
+ viewResource: '题目列表',
2622
2622
  // selectResource: '查找资源',
2623
2623
  }
2624
2624
  }
@@ -136,6 +136,7 @@
136
136
  </div>
137
137
  </div>
138
138
  </div>
139
+ <Paint v-if="paintShow" :title="paintText()" @exportImg="exportImg" :url="uploadImage?.url" @cancel="paintCancel"></Paint>
139
140
  </div>
140
141
  </template>
141
142
  <script>
@@ -155,6 +156,7 @@ import {CustomImage} from "./image-size";
155
156
  import {Contenteditable} from "./contenteditable";
156
157
  import svgs from "./level";
157
158
  import Mess from '../../tipBox/index'
159
+ import Paint from '../../paint/src/paint'
158
160
  import alignmentModeCenter from './img/center.png'
159
161
  import alignmentModeLeft from './img/left.png'
160
162
  import alignmentModeRight from './img/right.png'
@@ -164,7 +166,8 @@ export default {
164
166
  components: {
165
167
  EditorContent,
166
168
  BubbleMenu,
167
- svgs
169
+ svgs,
170
+ Paint
168
171
  },
169
172
  data() {
170
173
  return {
@@ -198,6 +201,7 @@ export default {
198
201
  editorRef: null,
199
202
  imgSizeVal: '',
200
203
  currentImgDom: {},
204
+ paintShow: false
201
205
  }
202
206
  },
203
207
  beforeUnmount() {
@@ -414,6 +418,18 @@ export default {
414
418
  })
415
419
  },
416
420
  methods: {
421
+ exportImg(e) {
422
+ this.uploadFile(e, this.uploadImage).then(r => {
423
+ this.paintShow = false
424
+ this.imgHtml(r.data)
425
+ })
426
+ },
427
+ paintText() {
428
+ return this.toolbar.filter(x => x.key === 'paint')[0]?.title
429
+ },
430
+ paintCancel() {
431
+ this.paintShow = false
432
+ },
417
433
  changeAlign(tag) {
418
434
  // 图片对齐方式
419
435
  this.editor.chain().setTextAlign(tag).run()
@@ -692,7 +708,6 @@ export default {
692
708
  })
693
709
  },
694
710
  upload(e, v) { // 上传文件
695
- console.log('ssdfasf');
696
711
  const file = e.target.files[0]
697
712
  if (this.uploadType) {
698
713
  if (v === 'uploadAtt') {
@@ -726,7 +741,6 @@ export default {
726
741
  },
727
742
  imgHtml(data) { // 插入图片
728
743
  setTimeout(() => {
729
- console.log('uploadImage100');
730
744
  const url = this.uploadImage.url + data
731
745
  const cla = this.randomId()
732
746
  const html = `<p class="imgCont ${cla}"><img src="${url}" alt="" width=""/></p>`
@@ -847,6 +861,7 @@ export default {
847
861
  this.editor.chain().focus().setFontSize('16px').setTextAlign('right').run()
848
862
  this.editor.chain().focus().setBold().run()
849
863
  }
864
+ if(v === 'paint') this.paintShow = true
850
865
  },
851
866
  getRandomCode(length) {
852
867
  if (length > 0) {
@@ -867,6 +882,7 @@ export default {
867
882
  </script>
868
883
 
869
884
  <style scoped>
885
+
870
886
  :deep(.w_100) {
871
887
  width: 100% !important;
872
888
  }
@@ -0,0 +1,6 @@
1
+ import main from './src/paint.vue';
2
+
3
+ main.install = function(Vue) {
4
+ Vue.component(main.name, main);
5
+ };
6
+ export default main;
@@ -0,0 +1,787 @@
1
+ <template>
2
+ <div class="paint" :id="ids">
3
+ <div class="paint-title">
4
+ <span>{{ title }}</span>
5
+ <div>
6
+ <button class="buts" @click="exportTap">确定</button>
7
+ <button class="buts" @click="cancel">取消</button>
8
+ </div>
9
+ </div>
10
+ <div class="paint-cont">
11
+ <Sketchpad ref="sketchpad"></Sketchpad>
12
+ </div>
13
+ <div class="tool-cont" :style="{left: left + 'px', top: top + 'px'}">
14
+ <div class="tool"
15
+ @mousedown.stop="mousedown"
16
+ @mouseup.stop="mouseup"
17
+ :id="ids + 'tool'">
18
+ <div class="tool-item" v-for="(item,index) in toolArr">
19
+ <div class="tool-img" :class="{'tool-arr-act': item.id === toolId}" :data-index="index">
20
+ <img :src="item.img" alt=""/>
21
+ </div>
22
+ <div class="prompt">{{ item.name }}</div>
23
+ </div>
24
+ </div>
25
+ <div class="tool-pop" v-if="toolMenu" :style="{bottom: toolTop + 'px', left: toolLeft + 'px'}">
26
+ <!--颜色-->
27
+ <div class="tool-pop-cont">
28
+ <div class="shape" v-if="['shape'].includes(this.toolId)">
29
+ <div class="tool-color">
30
+ <div class="tool-color-item" v-for="(item,index) in shapeData" @click="shapeTap(index)">
31
+ <div class="tool-color-select" :class="{'tool-active': shapeIndex === index}" :title="item.name">
32
+ <img :src="item.img" alt=""/>
33
+ </div>
34
+ </div>
35
+ </div>
36
+ </div>
37
+ <div class="link"></div>
38
+ <div class="tool-color">
39
+ <div class="tool-color-item" v-for="(item,index) in colorData" @click="colorTap(index)">
40
+ <div class="tool-color-select" :class="{'tool-active': colorIndex === index}" :title="item.name">
41
+ <div class="tool-color-col" :style="{'background-color': item.color}"></div>
42
+ </div>
43
+ </div>
44
+ </div>
45
+ <div class="link"></div>
46
+ <!--大小-->
47
+ <div class="tool-color" v-if="['pen','shape','text'].includes(this.toolId)">
48
+ <div class="tool-color-item" @click="sizeTap(index)" v-for="(item,index) in sizeData">
49
+ <div class="tool-color-select" :class="{'tool-active': sizeIndex === index}" :title="item.name">
50
+ <div class="tool-color-text">{{ item.text }}</div>
51
+ </div>
52
+ </div>
53
+ </div>
54
+ <div class="tool-color" v-if="['pen','shape'].includes(this.toolId)">
55
+ <div class="tool-color-item" @click="linkTap(index)" v-for="(item,index) in linkData">
56
+ <div class="tool-color-select" :class="{'tool-active': linkIndex === index}" :title="item.name">
57
+ <img :src="item.img" alt=""/>
58
+ </div>
59
+ </div>
60
+ </div>
61
+ <div class="tool-color" v-if="['shape'].includes(this.toolId)">
62
+ <div class="tool-color-item" @click="fillTap(index)" v-for="(item,index) in fillData">
63
+ <div class="tool-color-select" :class="{'tool-active': fillIndex === index}" :title="item.name">
64
+ <img :src="item.img" alt=""/>
65
+ </div>
66
+ </div>
67
+ </div>
68
+ <div class="tool-color" v-if="['text'].includes(this.toolId)">
69
+ <div class="tool-color-item" @click="fontTap(index)" v-for="(item,index) in fontData">
70
+ <div class="tool-color-select" :class="{'tool-active': fontIndex === index}" :title="item.name">
71
+ <img :src="item.img" alt=""/>
72
+ </div>
73
+ </div>
74
+ </div>
75
+ <!-- <div class="tool-color" v-if="['text'].includes(this.toolId)">-->
76
+ <!-- <div class="tool-color-item" @click="aligTap(index)" v-for="(item,index) in aligData">-->
77
+ <!-- <div class="tool-color-select" :class="{'tool-active': aligIndex === index}" :title="item.name">-->
78
+ <!-- <img :src="item.img" alt=""/>-->
79
+ <!-- </div>-->
80
+ <!-- </div>-->
81
+ <!-- </div>-->
82
+ </div>
83
+ </div>
84
+ </div>
85
+ <dragPopup v-if="show" :dragStatus="false" :minimizeCir="false" :enlargeShow="false" @close="close">
86
+ <template #content>
87
+ <div class="can">
88
+ <div class="can-cont" :id="ids + 'cont'">
89
+ <canvas :id="ids + 'can'"></canvas>
90
+ </div>
91
+ <div class="can-but">
92
+ <div class="can-but-cont">
93
+ <span @click="reset">重置</span>
94
+ <span @click="distinguish">{{ distinguishText }}</span>
95
+ </div>
96
+ </div>
97
+ </div>
98
+ <div class="can-pop" v-if="show2">
99
+ <div class="can-pop-cont">
100
+ <img ref="canPopCont" :src="appData" alt="" />
101
+ </div>
102
+ <div class="can-pop-but-cont">
103
+ <div class="can-pop-but" @click="addImage">确认</div>
104
+ </div>
105
+ </div>
106
+ </template>
107
+ </dragPopup>
108
+ </div>
109
+ </template>
110
+
111
+ <script>
112
+ import Sketchpad from '../../sketchpad/src/sketchpad'
113
+ import dragPopup from '../../dragPopup/src/dragPopup'
114
+
115
+ let stayTime = 0
116
+ let timer = null
117
+ export default {
118
+ components: {Sketchpad, dragPopup},
119
+ data() {
120
+ return {
121
+ show: false,
122
+ show2: false,
123
+ distinguishText: '识别',
124
+ colorIndex: 0,
125
+ sizeIndex: 0,
126
+ linkIndex: 0,
127
+ fillIndex: 0,
128
+ shapeIndex: 0,
129
+ fontIndex: 0,
130
+ aligIndex: 0,
131
+ toolArr: [
132
+ {id: 'choice', img: require('../src/img/huaban.png'), name: '选择'},
133
+ {id: 'pen', img: require('../src/img/bi.png'), name: '画笔'},
134
+ {id: 'shape', img: require('../src/img/tuxing.png'), name: '形状'},
135
+ {id: 'text', img: require('../src/img/wenzi.png'), name: '文字'},
136
+ {id: 'formula', img: require('../src/img/gongsi.png'), name: '公式'},
137
+ {id: 'rubber', img: require('../src/img/shanchu.png'), name: '橡皮'},
138
+ {id: 'clear', img: require('../src/img/qingchu.png'), name: '清屏'},
139
+ ],
140
+ colorData: [
141
+ {color: 'rgb(29, 29, 29)', name: '颜色-黑色', id: 'black'},
142
+ {color: 'rgb(159, 168, 178)', name: '颜色-灰色', id: 'grey'},
143
+ {color: 'rgb(224, 133, 244)', name: '颜色-浅紫色', id: 'light-violet'},
144
+ {color: 'rgb(174, 62, 201)', name: '颜色-紫色', id: 'violet'},
145
+ {color: 'rgb(68, 101, 233)', name: '颜色-蓝色', id: 'blue'},
146
+ {color: 'rgb(75, 161, 241)', name: '颜色-浅蓝色', id: 'light-blue'},
147
+ {color: 'rgb(241, 172, 75)', name: '颜色-黄色', id: 'yellow'},
148
+ {color: 'rgb(225, 105, 25)', name: '颜色-橙色', id: 'orange'},
149
+ {color: 'rgb(9, 146, 104)', name: '颜色-绿色', id: 'green'},
150
+ {color: 'rgb(76, 176, 94)', name: '颜色-浅绿色', id: 'light-green'},
151
+ {color: 'rgb(248, 119, 119)', name: '颜色-浅红色', id: 'light-red'},
152
+ {color: 'rgb(224, 49, 49)', name: '颜色-红色', id: 'red'},
153
+ ],
154
+ sizeData: [
155
+ {text: 'S', name: '大小-小', id: 's'},
156
+ {text: 'M', name: '大小-中', id: 'm'},
157
+ {text: 'L', name: '大小-大', id: 'l'},
158
+ {text: 'XL', name: '大小-加大', id: 'xl'},
159
+ ],
160
+ linkData: [
161
+ {img: require('../src/img/handwriting.png'), name: '划线-画笔', id: 'draw'},
162
+ {img: require('../src/img/virtual.png'), name: '划线-虚线', id: 'dashed'},
163
+ {img: require('../src/img/virtualRound.png'), name: '划线-虚点', id: 'dotted'},
164
+ {img: require('../src/img/lines.png'), name: '划线-实心', id: 'solid'},
165
+ ],
166
+ fillData: [
167
+ {img: require('../src/img/wu.png'), name: '填充-无', id: 'none'},
168
+ {img: require('../src/img/ban.png'), name: '填充-半填充', id: 'semi'},
169
+ {img: require('../src/img/quan.png'), name: '填充-全填充', id: 'solid'},
170
+ {img: require('../src/img/tuan.png'), name: '填充-图案', id: 'pattern'},
171
+ ],
172
+ fontData: [
173
+ {img: require('../src/img/case1.png'), name: '字体-画笔', id: 'draw'},
174
+ {img: require('../src/img/case.png'), name: '字体-无衬线', id: 'sans'},
175
+ {img: require('../src/img/case2.png'), name: '字体-衬线', id: 'serif'},
176
+ {img: require('../src/img/case3.png'), name: '字体-黑白', id: 'mono'},
177
+ ],
178
+ aligData: [
179
+ {img: require('../src/img/zuo.png'), name: '对齐-左对齐', id: 'start'},
180
+ {img: require('../src/img/zhong.png'), name: '对齐-居中', id: 'middle'},
181
+ {img: require('../src/img/you.png'), name: '对齐-右对齐', id: 'end'}
182
+ ],
183
+ shapeData: [
184
+ {img: require('../src/img/yuan.png'), name: '形状-圆', id: 'ellipse'},
185
+ {img: require('../src/img/sanjiao.png'), name: '形状-三角形', id: 'triangle'},
186
+ {img: require('../src/img/fang.png'), name: '形状-矩形', id: 'rectangle'},
187
+ {img: require('../src/img/lingxing.png'), name: '形状-菱形', id: 'rhombus'},
188
+ {img: require('../src/img/liubian.png'), name: '形状-六边形', id: 'hexagon'},
189
+ {img: require('../src/img/wujiao.png'), name: '形状-五角星', id: 'star'},
190
+ {img: require('../src/img/tixing.png'), name: '形状-梯形', id: 'trapezoid'},
191
+ {img: require('../src/img/yunduo.png'), name: '形状-云朵', id: 'cloud'},
192
+ ],
193
+ left: 0,
194
+ top: 0,
195
+ ids: null,
196
+ pressDown: false,
197
+ leftOffset: 0,
198
+ topOffset: '',
199
+ toolMenu: false,
200
+ toolTop: 0,
201
+ toolLeft: -160,
202
+ toolIndex: 0,
203
+ toolId: '',
204
+ num: '',
205
+ ctx: null,
206
+ canvasEle: null,
207
+ appData: ''
208
+ }
209
+ },
210
+ props: {
211
+ title: {
212
+ type: String,
213
+ default: ''
214
+ },
215
+ url: {
216
+ type: String,
217
+ default: ''
218
+ }
219
+ },
220
+ emits: ['cancel','exportImg'],
221
+ created() {
222
+ this.ids = this.randomId()
223
+ },
224
+ mounted() {
225
+ // 计算工具栏初始位置
226
+ const paint = document.getElementById(this.ids)
227
+ const tool = document.getElementById(this.ids + 'tool')
228
+ this.left = paint.offsetLeft + paint.offsetWidth - tool.offsetWidth - 20
229
+ this.top = paint.offsetTop + paint.offsetHeight / 2 - tool.offsetHeight / 2
230
+ // 绑定鼠标抬起事件
231
+ document.addEventListener('mouseup', this.mouseup)
232
+ // 绑定鼠标移动事件
233
+ document.addEventListener('mousemove', this.mousemove)
234
+ },
235
+ methods: {
236
+ exportTap() {
237
+ this.$refs.sketchpad.exportImg().then(res => {
238
+ this.$emit('exportImg', res)
239
+ })
240
+ },
241
+ // 添加公式图片
242
+ addImage() {
243
+ this.show = false
244
+ this.show2 = false
245
+ this.$refs.sketchpad.insertPicture({
246
+ width: this.$refs.canPopCont.offsetWidth,
247
+ height: this.$refs.canPopCont.offsetHeight,
248
+ src: this.appData
249
+ })
250
+ },
251
+ colorTap(i) {
252
+ this.colorIndex = i
253
+ this.toolTap()
254
+ },
255
+ sizeTap(i) {
256
+ this.sizeIndex = i
257
+ this.toolTap()
258
+ },
259
+ linkTap(i) {
260
+ this.linkIndex = i
261
+ this.toolTap()
262
+ },
263
+ fillTap(i) {
264
+ this.fillIndex = i
265
+ this.toolTap()
266
+ },
267
+ shapeTap(i) {
268
+ this.shapeIndex = i
269
+ this.toolTap()
270
+ },
271
+ fontTap(i) {
272
+ this.fontIndex = i
273
+ this.toolTap()
274
+ },
275
+ aligTap(i) {
276
+ this.aligIndex = i
277
+ this.toolTap()
278
+ },
279
+ toolTap() {
280
+ if(this.toolId === 'choice') {
281
+ this.$refs.sketchpad.select()
282
+ }
283
+ // 橡皮
284
+ if (this.toolId === 'clear') {
285
+ this.$refs.sketchpad.clear()
286
+ }
287
+ // 橡皮
288
+ if (this.toolId === 'rubber') {
289
+ this.$refs.sketchpad.eraser()
290
+ }
291
+ // 文字
292
+ if (this.toolId === 'text') {
293
+ this.$refs.sketchpad.text({
294
+ color: this.colorData[this.colorIndex].id,
295
+ size: this.sizeData[this.sizeIndex].id,
296
+ font: this.fontData[this.fontIndex].id
297
+ })
298
+ }
299
+ // 画笔
300
+ if (this.toolId === 'pen') {
301
+ this.$refs.sketchpad.draw({
302
+ color: this.colorData[this.colorIndex].id,
303
+ size: this.sizeData[this.sizeIndex].id,
304
+ dash: this.linkData[this.linkIndex].id
305
+ })
306
+ }
307
+ // 填充
308
+ if (this.toolId === 'shape') {
309
+ const pam = {
310
+ color: this.colorData[this.colorIndex].id,
311
+ size: this.sizeData[this.sizeIndex].id,
312
+ dash: this.linkData[this.linkIndex].id,
313
+ fill: this.fillData[this.fillIndex].id
314
+ }
315
+ if(this.shapeData[this.shapeIndex].id === 'ellipse') this.$refs.sketchpad.ellipse(pam)
316
+ if(this.shapeData[this.shapeIndex].id === 'triangle') this.$refs.sketchpad.triangle(pam)
317
+ if(this.shapeData[this.shapeIndex].id === 'rectangle') this.$refs.sketchpad.rectangle(pam)
318
+ if(this.shapeData[this.shapeIndex].id === 'rhombus') this.$refs.sketchpad.rhombus(pam)
319
+ if(this.shapeData[this.shapeIndex].id === 'hexagon') this.$refs.sketchpad.hexagon(pam)
320
+ if(this.shapeData[this.shapeIndex].id === 'star') this.$refs.sketchpad.star(pam)
321
+ if(this.shapeData[this.shapeIndex].id === 'trapezoid') this.$refs.sketchpad.trapezoid(pam)
322
+ if(this.shapeData[this.shapeIndex].id === 'cloud') this.$refs.sketchpad.cloud(pam)
323
+ }
324
+ // 公式
325
+ if (this.toolId === 'formula') {
326
+ this.show = !this.show
327
+ this.show2 = false
328
+ setTimeout(() => {
329
+ this.link() // 画线
330
+ }, 0)
331
+ }
332
+ },
333
+ dataURLtoBlob(dataurl) {
334
+ let arr = dataurl.split(',');
335
+ let mime = arr[0].match(/:(.*?);/)[1];
336
+ let bstr = atob(arr[1]);
337
+ let n = bstr.length;
338
+ let u8arr = new Uint8Array(n);
339
+ while (n--) {
340
+ u8arr[n] = bstr.charCodeAt(n);
341
+ }
342
+ return new Blob([u8arr], {type: mime});
343
+ },
344
+ // 识别
345
+ distinguish() {
346
+ this.distinguishText = '识别中'
347
+ const image = this.canvasEle.toDataURL("image/png");
348
+ let blob = this.dataURLtoBlob(image);
349
+ let file = new File([blob], "t.png", {lastModified: Date.now()});
350
+ this.HttpRequest(file).then(r => {
351
+ this.appData = r
352
+ this.distinguishText = '识别'
353
+ this.show2 = true
354
+ })
355
+ },
356
+ HttpRequest(file) {
357
+ return new Promise((rl,ri) => {
358
+ let token = null
359
+ let remember = localStorage.getItem('remember')
360
+ if (remember === '1') {
361
+ token = localStorage.getItem('sessionId')
362
+ } else {
363
+ token = sessionStorage.getItem('sessionId')
364
+ }
365
+ const xhr = new XMLHttpRequest()
366
+ let formData = new FormData();
367
+ formData.append('file', file);
368
+ xhr.open('POST', 'https://192.168.8.81:8081/zydx/latex/get')
369
+ xhr.setRequestHeader('Authorization', '276b6213-5937-49bd-9019-498ddb4dfd4f')
370
+ // xhr.open('GET', '/zydx/latex/get')
371
+ // xhr.setRequestHeader('Authorization', token)
372
+ this.error = true
373
+ xhr.onreadystatechange = () => {
374
+ if (xhr.readyState === 4) {
375
+ if (xhr.status === 200) {
376
+ rl(`${this.url}${JSON.parse(xhr.responseText).data}`)
377
+ }
378
+ }
379
+ }
380
+ xhr.send(formData)
381
+ })
382
+ },
383
+ // 清屏
384
+ reset() {
385
+ this.ctx.clearRect(0, 0, this.ctx.canvas.width, this.ctx.canvas.height);
386
+ },
387
+ // 画线
388
+ link() {
389
+ this.canvasEle = document.getElementById(this.ids + 'can')
390
+ const cont = document.getElementById(this.ids + 'cont')
391
+ this.ctx = this.canvasEle.getContext('2d')
392
+ this.canvasEle.width = cont.offsetWidth;
393
+ this.canvasEle.height = cont.offsetHeight;
394
+ let isDrawing = false;
395
+ let x = 0;
396
+ let y = 0;
397
+ this.canvasEle.addEventListener("mousedown", (event) => {
398
+ x = event.offsetX;
399
+ y = event.offsetY;
400
+ isDrawing = true;
401
+ });
402
+
403
+ this.canvasEle.addEventListener("mousemove", (event) => {
404
+ if (isDrawing) {
405
+ this.drawLine(this.ctx, x, y, event.offsetX, event.offsetY);
406
+ x = event.offsetX;
407
+ y = event.offsetY;
408
+ }
409
+ });
410
+
411
+ this.canvasEle.addEventListener("mouseup", (event) => {
412
+ this.drawLine(this.ctx, x, y, event.offsetX, event.offsetY);
413
+ x = 0;
414
+ y = 0;
415
+ isDrawing = false;
416
+ })
417
+ },
418
+ drawLine(ctx, x, y, lx, ly) {
419
+ ctx.beginPath()
420
+ ctx.strokeStyle = '#000'
421
+ ctx.lineWidth = 1
422
+ ctx.moveTo(x, y)
423
+ ctx.lineTo(lx, ly)
424
+ ctx.lineCap = 'round'
425
+ ctx.lineJoin = 'round'
426
+ ctx.stroke()
427
+ ctx.closePath()
428
+ },
429
+ close2() {
430
+ this.show2 = false
431
+ },
432
+ close() {
433
+ this.show = false
434
+ },
435
+ mousedown(e) {
436
+ e.preventDefault()
437
+ let x = e.offsetX
438
+ let y = e.offsetY
439
+ this.toolIndex = e.target.dataset.index
440
+ if (this.toolIndex) {
441
+ x = e.offsetX + 5
442
+ y = e.offsetY + this.toolIndex * (28 + 5)
443
+ }
444
+ this.leftOffset = x;
445
+ this.topOffset = y;
446
+ this.pressDown = true
447
+ timer = setInterval(() => {
448
+ stayTime += 100
449
+ }, 100)
450
+ },
451
+ mousemove(e) {
452
+ if (!this.pressDown) return
453
+ this.left = e.clientX - this.leftOffset;
454
+ this.top = e.clientY - this.topOffset;
455
+ },
456
+ mouseup(e) {
457
+ clearInterval(timer)
458
+ if (stayTime <= 100 && this.pressDown) { // 如果小于100就是点击事件
459
+ if (!this.toolArr[this.toolIndex]) {
460
+ stayTime = 0
461
+ this.pressDown = false
462
+ return
463
+ }
464
+ this.toolId = this.toolArr[this.toolIndex].id
465
+ this.toolTap()
466
+ const hei = e.target.parentNode.parentNode.offsetHeight
467
+ this.toolTop = -(Number(this.toolIndex) * (28 + 5)) - 50 + hei
468
+ // 判断是否显示工具菜单
469
+ if (['1', '2', '3'].includes(this.toolIndex)) {
470
+ if (this.num === this.toolIndex) {
471
+ this.toolMenu = !this.toolMenu
472
+ } else {
473
+ this.toolMenu = true
474
+ }
475
+ this.num = this.toolIndex
476
+ } else {
477
+ this.toolMenu = false
478
+ }
479
+ }
480
+ stayTime = 0
481
+ this.pressDown = false
482
+ },
483
+ randomId() { // 生成随机id
484
+ const id = Math.random().toString(36).substr(2)
485
+ return id.replace(/[0-9]/g, '')
486
+ },
487
+ cancel() {
488
+ this.$emit('cancel')
489
+ }
490
+ }
491
+ }
492
+ </script>
493
+
494
+ <style scoped>
495
+ .can-pop{
496
+ position: fixed;
497
+ top: 50%;
498
+ left: 50%;
499
+ z-index: 1200;
500
+ background: #fff;
501
+ box-shadow: 0 0 8px 0 rgba(0, 0, 0, 0.2);
502
+ width: 200px;
503
+ height: 200px;
504
+ margin-left: -100px;
505
+ margin-top: -100px;
506
+ }
507
+ .can-pop-cont{
508
+ width: 100%;
509
+ height: 160px;
510
+ display: flex;
511
+ align-items: center;
512
+ }
513
+ .can-pop-cont > img{
514
+ max-width: 100%;
515
+ max-height: 100%;
516
+ margin: 0 auto;
517
+ }
518
+ .can {
519
+ padding: 10px;
520
+ height: 100%;
521
+ }
522
+ .can-pop-but-cont{
523
+ text-align: center;
524
+ }
525
+
526
+ .can-cont {
527
+ width: 100%;
528
+ height: calc(100% - 30px);
529
+ border: 1px solid #ccc;
530
+ cursor: crosshair;
531
+ }
532
+
533
+ .can-cont canvas {
534
+ width: 100%;
535
+ height: 100%;
536
+ }
537
+ .can-cont img{
538
+ width: 100%;
539
+ height: 100%;
540
+ }
541
+
542
+ .can-but {
543
+ width: 100%;
544
+ height: 30px;
545
+ text-align: center;
546
+ }
547
+
548
+ .can-but-cont {
549
+ display: inline-block;
550
+ padding-top: 5px;
551
+ }
552
+
553
+ .can-but-cont > span, .can-pop-but {
554
+ display: inline-block;
555
+ width: 80px;
556
+ height: 25px;
557
+ background: #c64c10;
558
+ color: #fff;
559
+ line-height: 25px;
560
+ margin: 0 5px;
561
+ border-radius: 3px;
562
+ cursor: pointer;
563
+ text-align: center;
564
+ }
565
+
566
+ .link {
567
+ border-top: 1px solid #dedede;
568
+ }
569
+
570
+ .tool-color {
571
+ display: flex;
572
+ flex-wrap: wrap;
573
+ }
574
+
575
+ .tool-color-item {
576
+ width: 37px;
577
+ height: 37px;
578
+ padding: 3px;
579
+ box-sizing: border-box;
580
+ }
581
+
582
+ .tool-color-select {
583
+ border-radius: 5px;
584
+ width: 100%;
585
+ height: 100%;
586
+ cursor: pointer;
587
+ display: flex;
588
+ align-items: center;
589
+ }
590
+
591
+ .tool-color-select img {
592
+ width: 18px;
593
+ height: 18px;
594
+ margin: 0 auto;
595
+ }
596
+
597
+ .tool-color-text {
598
+ text-align: center;
599
+ font-weight: bold;
600
+ margin: 0 auto;
601
+ font-size: 14px;
602
+ }
603
+
604
+ .tool-color-select:hover {
605
+ background-color: rgba(0, 0, 0, 0.1);
606
+ }
607
+ .tool-active{
608
+ background-color: rgba(0, 0, 0, 0.1);
609
+ }
610
+
611
+ .tool-color-col {
612
+ width: 18px;
613
+ height: 18px;
614
+ border-radius: 50%;
615
+ margin: 0 auto;
616
+ }
617
+
618
+ .tool-pop {
619
+ position: absolute;
620
+ background-color: #fff;
621
+ border-radius: 5px;
622
+ z-index: 1;
623
+ box-shadow: 0 0 4px rgba(0, 0, 0, 0.25);
624
+ width: 150px;
625
+ }
626
+
627
+ .tool-pop-cont {
628
+ width: 100%;
629
+ height: 100%;
630
+ background-color: #fff;
631
+ border-radius: 5px;
632
+ position: relative;
633
+ z-index: 3;
634
+ }
635
+
636
+ .tool-pop:before {
637
+ position: absolute;
638
+ bottom: 30px;
639
+ right: -6px;
640
+ content: '';
641
+ width: 0;
642
+ border: 6px solid #FFFFFF;
643
+ transform: rotate(-45deg);
644
+ box-shadow: 0 0 8px 0 rgba(0, 0, 0, 0.2);
645
+ margin-top: -5px;
646
+ }
647
+
648
+ .prompt {
649
+ position: absolute;
650
+ top: -38px;
651
+ left: -10px;
652
+ background-color: #000;
653
+ color: #fff;
654
+ border-radius: 5px;
655
+ padding: 5px 0;
656
+ width: 50px;
657
+ text-align: center;
658
+ display: none;
659
+ }
660
+
661
+ .prompt:after {
662
+ content: '';
663
+ width: 0;
664
+ height: 0;
665
+ border-left: 6px solid transparent;
666
+ border-right: 6px solid transparent;
667
+ border-top: 6px solid #000;
668
+ position: absolute;
669
+ bottom: -6px;
670
+ left: 50%;
671
+ margin-left: -6px;
672
+ }
673
+
674
+ .tool {
675
+ width: 40px;
676
+ border-radius: 3px;
677
+ background: #FFFFFF;
678
+ box-shadow: 0 0 4px rgba(0, 0, 0, 0.25);
679
+ box-sizing: border-box;
680
+ padding: 5px;
681
+ user-select: none;
682
+ }
683
+
684
+ .tool-cont {
685
+ position: fixed;
686
+ z-index: 200;
687
+ }
688
+
689
+ .tool-item {
690
+ width: 100%;
691
+ height: 28px;
692
+ margin-top: 5px;
693
+ cursor: pointer;
694
+ background-color: #F2F2F2;
695
+ border-radius: 3px;
696
+ position: relative;
697
+ }
698
+
699
+ .tool-item:first-child {
700
+ margin-top: 0;
701
+ }
702
+
703
+ .tool-item:hover {
704
+ background-color: #00FF00;
705
+ }
706
+
707
+ .tool-item:hover .prompt {
708
+ display: block;
709
+ }
710
+
711
+ .tool-img {
712
+ width: 100%;
713
+ height: 100%;
714
+ overflow: hidden;
715
+ display: flex;
716
+ align-items: center;
717
+ }
718
+
719
+ .tool-img > img {
720
+ width: 70%;
721
+ height: 70%;
722
+ border-radius: 3px;
723
+ margin: 0 auto;
724
+ }
725
+ .tool-arr-act{
726
+ background-color: #00FF00;
727
+ border-radius: 3px;
728
+ }
729
+ .tool-arr-act img{
730
+ filter: drop-shadow(30px 0 0 #fff);
731
+ position: relative;
732
+ left: -30px;
733
+ }
734
+ .tool-item:hover img {
735
+ filter: drop-shadow(30px 0 0 #fff);
736
+ position: relative;
737
+ left: -30px;
738
+ }
739
+
740
+ .paint-cont {
741
+ border: 1px solid rgba(204, 204, 204, 1);
742
+ width: 100%;
743
+ height: calc(100% - 34px);
744
+ }
745
+
746
+ .paint {
747
+ position: fixed;
748
+ top: 50%;
749
+ left: 50%;
750
+ z-index: 10;
751
+ width: 940px;
752
+ height: 687px;
753
+ margin-left: -420px;
754
+ margin-top: -344px;
755
+ background-color: #fff;
756
+ box-shadow: 0 0 4px rgba(0, 0, 0, 0.25);
757
+ padding: 0 10px 10px 10px;
758
+ }
759
+
760
+ .paint-title {
761
+ font-size: 14px;
762
+ height: 34px;
763
+ line-height: 34px;
764
+ display: flex;
765
+ justify-content: space-between;
766
+ }
767
+
768
+ .buts {
769
+ margin-left: 1px;
770
+ font-size: 12px;
771
+ background-color: transparent;
772
+ border: 1px solid #000;
773
+ border-radius: 3px;
774
+ padding: 2px 5px;
775
+ cursor: pointer;
776
+ min-width: 60px;
777
+ height: 20px;
778
+ display: inline-block;
779
+ line-height: 16px;
780
+ box-sizing: border-box;
781
+ font-family: Arial;
782
+ -moz-text-align-last: justify;
783
+ text-align-last: justify;
784
+ word-break: break-all;
785
+ text-justify: distribute;
786
+ }
787
+ </style>
@@ -1,11 +1,12 @@
1
1
  <template>
2
2
  <div ref="reactRef" class="react"></div>
3
+ <canvas id="canvas"></canvas>
3
4
  </template>
4
5
 
5
6
  <script>
6
7
  import {createElement} from 'react'
7
8
  import {createRoot} from 'react-dom/client'
8
- import {AssetRecordType,createShapeId, Tldraw} from 'tldraw'
9
+ import {AssetRecordType,createShapeId, Tldraw, FileHelpers} from 'tldraw'
9
10
  import 'tldraw/tldraw.css'
10
11
 
11
12
  const clearJson = {
@@ -95,6 +96,39 @@ export default {
95
96
  }, null))
96
97
  },
97
98
  methods: {
99
+ exportImg() {
100
+ return new Promise((rl,ri) => {
101
+ editorAPP.getSvg([...editorAPP.getCurrentPageShapeIds()],{}).then(r => {
102
+ const s = new XMLSerializer().serializeToString(r);
103
+ const src = `data:image/svg+xml;base64,${window.btoa(s)}`;
104
+ const img = new Image(); // 创建图片容器承载过渡
105
+ img.src = src;
106
+ img.onload = () => {
107
+ // ↓ 第二部分
108
+ const canvas = document.createElement('canvas');
109
+ canvas.width = img.width;
110
+ canvas.height = img.height;
111
+ const context = canvas.getContext('2d');
112
+ context.drawImage(img, 0, 0);
113
+ const ImgBase64 = canvas.toDataURL('image/png');
114
+ let blob = this.dataURLtoBlob(ImgBase64);
115
+ let file = new File([blob], `${new Date().getTime()}.png`, {lastModified: Date.now()});
116
+ rl(file)
117
+ }
118
+ })
119
+ })
120
+ },
121
+ dataURLtoBlob(dataurl) {
122
+ let arr = dataurl.split(',');
123
+ let mime = arr[0].match(/:(.*?);/)[1];
124
+ let bstr = atob(arr[1]);
125
+ let n = bstr.length;
126
+ let u8arr = new Uint8Array(n);
127
+ while (n--) {
128
+ u8arr[n] = bstr.charCodeAt(n);
129
+ }
130
+ return new Blob([u8arr], {type: mime});
131
+ },
98
132
  handleMountedEditor(editor) {
99
133
  editorAPP = editor
100
134
  setTimeout(() => {
@@ -146,7 +180,7 @@ export default {
146
180
  this.styleProps('text', 'color').defaultValue = v?.color ?? 'black'
147
181
  this.styleProps('text', 'size').defaultValue = v?.size ?? 'm'
148
182
  this.styleProps('text', 'font').defaultValue = v?.font ?? 'draw' //['draw', 'sans', 'serif', 'mono']
149
- // this.styleProps('text', 'align').defaultValue = v?.align ?? 'start'
183
+ this.styleProps('text', 'align').defaultValue = v?.align ?? 'start'
150
184
  editorAPP.setCurrentTool('text')
151
185
  },
152
186
  note(v) {
@@ -348,6 +382,7 @@ export default {
348
382
  },
349
383
  styleProps(t, e) {
350
384
  const style = [...editorAPP.styleProps[t]]
385
+ console.log(style)
351
386
  const index = style.findIndex(item => item[1] === e)
352
387
  return style[index][0]
353
388
  },
@@ -368,4 +403,10 @@ export default {
368
403
  width: 100%;
369
404
  height: 100%;
370
405
  }
406
+ #canvas{
407
+ position: fixed;
408
+ top: -99999px;
409
+ left: 0;
410
+ z-index: -1;
411
+ }
371
412
  </style>
package/src/index.js CHANGED
@@ -83,7 +83,7 @@ function install(app) {
83
83
  }
84
84
 
85
85
  export default {
86
- version: '1.33.430',
86
+ version: '1.33.432',
87
87
  install,
88
88
  Calendar,
89
89
  Message,