zydx-plus 1.32.258 → 1.32.260

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zydx-plus",
3
- "version": "1.32.258",
3
+ "version": "1.32.260",
4
4
  "description": "Vue.js",
5
5
  "main": "src/index.js",
6
6
  "files": [
@@ -7,6 +7,9 @@
7
7
  <button v-if="item.key === 'but'" class="buts" @click="item.onClick(item,info)"
8
8
  :style="{color: (item.active)? '#00ff00' :'#000'}">{{ item.title }}
9
9
  </button>
10
+ <button v-if="item.key === 'speech'" class="buts" @mousedown.stop="speechDown" @click="item.onClick(item)"
11
+ :style="{color: (item.active)? '#00ff00' :'#000'}">{{ voiceStatus ? '关闭语音' : '语音输入' }}
12
+ </button>
10
13
  <label v-else-if="item.key === 'upImg' || item.key === 'uploadAtt'">
11
14
  <input type="file" @change="upload($event,item.key)"
12
15
  :accept="(item.key === 'upImg')?'image/*':'.docx,.pptx,.pdf,.xlsx,.mp3,.mp4'" style="display: none;">
@@ -14,23 +17,21 @@
14
17
  </label>
15
18
  <button v-else class="buts" @click="toolTap(item.key)">{{ item.title }}</button>
16
19
  </div>
17
- <div class="voice">
18
- <button class="buts" @click="voice" :style="{color: (voiceStatus)? '#00ff00' :'#000'}">
19
- {{ voiceStatus ? '关闭语音' : '语音输入' }}
20
- </button>
21
- </div>
22
20
  </div>
23
21
  </div>
24
22
  <div class="ed-cont" :style="heightStyleCont">
25
- <div :style="{'border': (borderShow)? '1px solid #ccc': '0'}" v-if="editorShow">
23
+ <div :style="{'border': (borderShow)? '1px solid #ccc': '0'}" v-if="editorShow">
26
24
  <editor-content @paste.native.capture.prevent="preventPaste" ref="editorRef" class="editor" :editor="editor"
27
25
  :style="heightStyleCont"/>
28
26
  </div>
29
- <div v-if="voiceStatus" class="speak">
27
+ <div v-if="voiceStatus" class="speak"
28
+ @mousedown.stop="mousedown"
29
+ @mouseup.stop="mouseup"
30
+ :style="{transform: `translate(${x}px, ${y}px)`}">
30
31
  <div class="speak-cont">
31
32
  <svg t="1698630789078" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4553" width="15" height="15"><path d="M533.84533333 930.88426667c-13.65333333 0-24.576-10.92266667-24.576-24.576v-122.33386667c0-13.65333333 10.92266667-24.576 24.576-24.576s24.576 10.92266667 24.576 24.576v122.33386667c-0.54613333 13.65333333-11.4688 24.576-24.576 24.576zM533.84533333 686.21653333c-101.03466667 0-183.5008-82.46613333-183.5008-183.5008V258.048c0-101.03466667 82.46613333-183.5008 183.5008-183.5008s183.5008 82.46613333 183.5008 183.5008v244.66773333c0 101.03466667-82.46613333 183.5008-183.5008 183.5008z m0-563.06346666c-74.27413333 0-134.89493333 60.6208-134.89493333 134.89493333v244.66773333c0 74.27413333 60.6208 134.89493333 134.89493333 134.89493334s134.89493333-60.6208 134.89493334-134.89493334V258.048c-0.54613333-74.27413333-60.6208-134.89493333-134.89493334-134.89493333z" fill="#fff" p-id="4554"></path><path d="M533.84533333 808.5504c-168.7552 0-305.83466667-137.07946667-305.83466666-305.83466667 0-13.65333333 10.92266667-24.576 24.576-24.576s24.576 10.92266667 24.576 24.576c0 141.99466667 115.23413333 257.2288 257.2288 257.2288S790.528 644.7104 790.528 502.71573333c0-13.65333333 10.92266667-24.576 24.576-24.576s24.576 10.92266667 24.576 24.576c0 168.7552-137.07946667 305.83466667-305.83466667 305.83466667zM729.36106667 955.46026667H337.78346667c-13.65333333 0-24.576-10.92266667-24.576-24.576s10.92266667-24.576 24.576-24.576h391.5776c13.65333333 0 24.576 10.92266667 24.576 24.576s-10.92266667 24.576-24.576 24.576z" fill="#FFF" p-id="4555"></path></svg>
32
33
  <svgs :vol="vol"></svgs>
33
- <span>{{ error? '开启语音失败' : '正在说话...' }}</span>
34
+ <span>{{ error? '连接中...' : '正在说话...' }}</span>
34
35
  <svg style="cursor: pointer" @click="close" t="1698630749910" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4415" width="20" height="20"><path d="M726.976 274.432a16 16 0 0 0-22.656 0L512 466.752l-192.32-192.32a16 16 0 0 0-22.624 0l-22.656 22.624a16 16 0 0 0 0 22.624l192.32 192.32-192.32 192.32a16 16 0 0 0 0 22.656l22.656 22.624a16 16 0 0 0 22.624 0l192.32-192.32 192.32 192.32a16 16 0 0 0 22.656 0l22.624-22.624a16 16 0 0 0 0-22.624L557.28 512l192.32-192.352a16 16 0 0 0 0-22.624l-22.624-22.624z" fill="#fff" p-id="4416"></path></svg>
35
36
  </div>
36
37
  </div>
@@ -128,7 +129,14 @@ export default {
128
129
  vol: 0,
129
130
  appData: {},
130
131
  error: false,
131
- time: {}
132
+ time: {},
133
+ toolbars: [],
134
+ left: 0,
135
+ top: 0,
136
+ isMove: false,
137
+ x: 0,
138
+ y: 0,
139
+ speech: {}
132
140
  }
133
141
  },
134
142
  beforeUnmount() {
@@ -136,6 +144,7 @@ export default {
136
144
  this.recorder?.destroy()
137
145
  this.ws?.send(JSON.stringify({"type":"CANCEL"}))
138
146
  this.ws?.close()
147
+ this.ws = null
139
148
  },
140
149
  props: {
141
150
  data: {
@@ -245,6 +254,22 @@ export default {
245
254
  })
246
255
  },
247
256
  deep: true
257
+ },
258
+ toolbar: {
259
+ handler: function (e, oldVal) {
260
+ e.map(x => {
261
+ if (x.key === 'speech') {
262
+ this.voiceStatus = x.active
263
+ if(this.voiceStatus) {
264
+ this.voice()
265
+ }else {
266
+ this.close()
267
+ }
268
+ }
269
+ return x
270
+ })
271
+ },
272
+ deep: true
248
273
  }
249
274
  },
250
275
  mounted() {
@@ -297,7 +322,6 @@ export default {
297
322
  }
298
323
  }
299
324
  })
300
- _this.appID()
301
325
  // 初始化录音
302
326
  this.recorder = new Recorder({
303
327
  sampleBits: 16, // 采样位数,支持 8 或 16,默认是16
@@ -307,8 +331,29 @@ export default {
307
331
  this.recorder.onprogress = function (params) {
308
332
  _this.vol = params.vol
309
333
  }
334
+ document.addEventListener('mousemove', (event) => {
335
+ if (!this.isMove) return
336
+ this.x = event.clientX - this.left;
337
+ this.y = event.clientY - this.top;
338
+ })
310
339
  },
311
340
  methods: {
341
+ speechDown(e) {
342
+ this.speech = {
343
+ x: e.clientX - e.offsetX,
344
+ y: e.clientY - e.offsetY,
345
+ }
346
+ },
347
+ mousedown(event) {
348
+ event.preventDefault()
349
+ //鼠标按下事件
350
+ this.left = event.offsetX;
351
+ this.top = event.offsetY;
352
+ this.isMove = true
353
+ },
354
+ mouseup() {
355
+ this.isMove = false
356
+ },
312
357
  // 粘贴文本处理
313
358
  preventPaste(event) {
314
359
  const text = event.clipboardData.getData('text/plain');
@@ -363,35 +408,40 @@ export default {
363
408
  scriptProcessor.connect(that.recorder.context.destination);
364
409
  },
365
410
  voice() {
366
- let that = this
367
- that.voiceStatus = !this.voiceStatus
368
- if(that.voiceStatus) {
369
- this.recorder.start().then(() => { // 开始录音
370
- this.audioData = []
371
- this.webSocketInit()
372
- }, (error) => {
373
- this.$message({
374
- type: 'text',
375
- cancelShow: false,
376
- promptContent: '录音失败,请检查麦克风是否可用'
377
- })
378
- });
379
- }else {
380
- that.close()
381
- }
411
+ this.recorder.start().then(() => { // 开始录音
412
+ this.audioData = []
413
+ this.x = this.speech.x - 85
414
+ const h = this.height.split('px')[0]
415
+ this.y = this.speech.y + ((this.height === '100%') ? 40 : Number(h) - 10)
416
+ this.appID()
417
+ }, (error) => {
418
+ this.$message({
419
+ type: 'text',
420
+ cancelShow: false,
421
+ promptContent: '录音失败,请检查麦克风是否可用'
422
+ })
423
+ });
382
424
  },
383
425
  close() {
426
+ if(this.ws === null) return
427
+ this.toolbar.map(x => {
428
+ if (x.key === 'speech') {
429
+ x.active = false
430
+ }
431
+ return x
432
+ })
384
433
  this.voiceStatus = false
385
- this.ws.send(JSON.stringify({"type":"CANCEL"}))
386
- this.ws.close()
434
+ this.ws?.send(JSON.stringify({"type":"CANCEL"}))
435
+ this.ws?.close()
436
+ this.ws = null
387
437
  this.recorder.stop() // 停止录音
388
438
  this.recorder.destroy()
389
439
  },
390
440
  webSocketInit() {
391
441
  const _this = this
392
- _this.ws = new WebSocket(`wss://vop.baidu.com/realtime_asr?sn=${this.getRandomCode(15)}`)
393
- _this.ws.binaryType = 'arraybuffer'
394
- _this.ws.onopen = function () {
442
+ this.ws = new WebSocket(`wss://vop.baidu.com/realtime_asr?sn=${this.getRandomCode(15)}`)
443
+ this.ws.binaryType = 'arraybuffer'
444
+ this.ws.onopen = function () {
395
445
  _this.error = false
396
446
  const json = {
397
447
  type: 'START',
@@ -407,7 +457,7 @@ export default {
407
457
  _this.ws.send(JSON.stringify(json))
408
458
  _this.getAudioSuccess()
409
459
  }
410
- _this.ws.onmessage = function (e) {
460
+ this.ws.onmessage = function (e) {
411
461
  const data = JSON.parse(e.data)
412
462
  if(data.err_no === 0){
413
463
  const json = _this.editor.getJSON()
@@ -422,10 +472,9 @@ export default {
422
472
  _this.time = data
423
473
  }
424
474
  }
425
- _this.ws.onerror = function () {
475
+ this.ws.onerror = function () {
426
476
  // 连接失败重连
427
477
  setTimeout(() => {
428
- _this.error = true
429
478
  _this.webSocketInit()
430
479
  }, 5000)
431
480
  }
@@ -439,14 +488,16 @@ export default {
439
488
  token = sessionStorage.getItem('sessionId')
440
489
  }
441
490
  const xhr = new XMLHttpRequest()
442
- // xhr.open('GET', 'http://192.168.15.126:8888/zydx/voice/getDesKeyId')
443
- // xhr.setRequestHeader('Authorization', 'e891f5a9-4cf0-4f9f-b969-c91d44e6648c')
444
- xhr.open('GET', '/zydx/voice/getDesKeyId')
445
- xhr.setRequestHeader('Authorization', token)
491
+ xhr.open('GET', 'http://192.168.15.124:8888/zydx/voice/getDesKeyId')
492
+ xhr.setRequestHeader('Authorization', 'dd9fabcd-ca68-4f1a-97f0-21a66628207d')
493
+ // xhr.open('GET', '/zydx/voice/getDesKeyId')
494
+ // xhr.setRequestHeader('Authorization', token)
495
+ this.error = true
446
496
  xhr.onreadystatechange = () => {
447
497
  if (xhr.readyState === 4) {
448
498
  if (xhr.status === 200) {
449
499
  this.appData = JSON.parse(xhr.responseText).data
500
+ this.webSocketInit()
450
501
  }
451
502
  }
452
503
  }
@@ -657,8 +708,11 @@ export default {
657
708
 
658
709
  <style scoped>
659
710
  .speak{
660
- text-align: right;
661
- padding: 5px 0;
711
+ position: fixed;
712
+ top: 0;
713
+ left: 0;
714
+ z-index: 50;
715
+ cursor: move;
662
716
  }
663
717
  .speak-cont{
664
718
  background: rgba(67, 207, 124, 1);
@@ -812,6 +866,7 @@ export default {
812
866
  .ed-cont {
813
867
  padding-top: 4px;
814
868
  margin-bottom: 14px;
869
+ position: relative;
815
870
  }
816
871
 
817
872
  .editor {
@@ -1,452 +1,510 @@
1
1
  <template>
2
- <div class="sketchpad">
3
- <canvas :id="id"></canvas>
4
- <div class="tool">
5
- <div class="tool-list" @click="set">
6
- <img src="./img/shezi.png" alt="" />
7
- <div v-if="setShow" class="set">
8
- <div class="set-list">
9
- <span>线条粗细</span>
10
- <em v-for="(item,index) in strokeData" @click="strokeTap(item)">{{ item }}</em>
11
- </div>
12
- <div class="set-list">
13
- <span>线条颜色</span>
14
- <i v-for="(item,index) in strokeColor" @click="strokeColTap(item)" :style="{'background-color': item}"></i>
15
- </div>
16
- </div>
17
- </div>
18
- <div class="tool-list" @click="brush">
19
- <img src="./img/huabi.png" alt="" />
20
- </div>
21
- <div class="tool-list" @click="rectangle">
22
- <img src="./img/juxing.png" alt="" />
23
- </div>
24
- <div class="tool-list" @click="addTextBox">
25
- <img src="./img/wenzi.png" alt="" />
26
- <div v-if="textShow" class="set">
27
- <div class="set-list">
28
- <span>字号</span>
29
- <em style="font-size: 13px;" v-for="(item,index) in textData" @click.stop="sizeTap(item)">{{ item }}</em>
30
- </div>
31
- <div class="set-list">
32
- <span>内容</span>
33
- <input type="text" v-model="text" @click.stop="false" />
34
- </div>
35
- <div class="set-list set-right">
36
- <button class="but" @click="textBox">确认</button>
37
- </div>
38
- </div>
39
- </div>
40
- <div class="tool-list" @click="rotundity">
41
- <img src="./img/yuan.png" alt="" />
42
- </div>
43
- <div class="tool-list" @click="addLine">
44
- <img src="./img/jian.png" alt="" />
45
- </div>
46
- <div class="tool-list" @click="arrow">
47
- <img src="./img/jiantou.png" alt="" />
48
- </div>
49
- <div class="tool-list" @click="save">
50
- <img src="./img/baocun.png" alt="" />
51
- </div>
52
- <div class="tool-list" @click="clear">
53
- <img src="./img/xiangpi.png" alt="" />
54
- </div>
2
+ <div class="sketchpad" ref="sketchpad">
3
+ <canvas :id="id"></canvas>
4
+ <div class="tool"
5
+ @mouseup.stop="mouseup"
6
+ @mousedown.stop="mousedown"
7
+ :style="{transform: `translate(${x}px, ${y}px)`}">
8
+ <div class="tool-list" @click.stop="set">
9
+ <img src="./img/shezi.png" alt=""/>
10
+ <div v-if="setShow" class="set">
11
+ <div class="set-list">
12
+ <span>线条粗细</span>
13
+ <em v-for="(item,index) in strokeData" @click="strokeTap(item)">{{ item }}</em>
14
+ </div>
15
+ <div class="set-list">
16
+ <span>线条颜色</span>
17
+ <i v-for="(item,index) in strokeColor" @click="strokeColTap(item)" :style="{'background-color': item}"></i>
18
+ </div>
55
19
  </div>
20
+ </div>
21
+ <div class="tool-list" @click.stop="brush">
22
+ <img src="./img/huabi.png" alt=""/>
23
+ </div>
24
+ <div class="tool-list" @click.stop="rectangle">
25
+ <img src="./img/juxing.png" alt=""/>
26
+ </div>
27
+ <div class="tool-list" @click.stop="addTextBox">
28
+ <img src="./img/wenzi.png" alt=""/>
29
+ <div v-if="textShow" class="set">
30
+ <div class="set-list">
31
+ <span>字号</span>
32
+ <em style="font-size: 13px;" v-for="(item,index) in textData" @click.stop="sizeTap(item)">{{ item }}</em>
33
+ </div>
34
+ <div class="set-list">
35
+ <span>内容</span>
36
+ <input type="text" v-model="text" @click.stop="false"/>
37
+ </div>
38
+ <div class="set-list set-right">
39
+ <button class="but" @click="textBox">确认</button>
40
+ </div>
41
+ </div>
42
+ </div>
43
+ <div class="tool-list" @click.stop="rotundity">
44
+ <img src="./img/yuan.png" alt=""/>
45
+ </div>
46
+ <div class="tool-list" @click.stop="addLine">
47
+ <img src="./img/jian.png" alt=""/>
48
+ </div>
49
+ <div class="tool-list" @click.stop="arrow">
50
+ <img src="./img/jiantou.png" alt=""/>
51
+ </div>
52
+ <div class="tool-list" @click.stop="save">
53
+ <img src="./img/baocun.png" alt=""/>
54
+ </div>
55
+ <div class="tool-list" @click.stop="clear">
56
+ <img src="./img/xiangpi.png" alt=""/>
57
+ </div>
56
58
  </div>
59
+ </div>
57
60
  </template>
58
61
 
59
62
  <script>
60
- import { fabric } from 'fabric'
63
+ import {fabric} from 'fabric'
64
+
61
65
  export default {
62
- name: "zydx-sketchpad",
63
- data() {
64
- return {
65
- canvas: null,
66
- strokeWidth: 2, // 线条粗细
67
- color: '#000', // 线条颜色
68
- line: null, // 线条
69
- isDown: false, // 是否按下
70
- state: null, // 状态
71
- rect: null, // 矩形
72
- circle: null, // 圆形
73
- fontSize: 14, // 字体大小
74
- setShow: false, // 设置
75
- strokeData: ['1','2','3','4','5','6','7'], // 画笔数据
76
- strokeColor: ['#000','#f00','#0f0','#00f','#f0f','#ff0','#0ff'], // 画笔颜色
77
- textShow: false, // 文本
78
- textData: ['14','16','18','20','22','24','28','30'], // 文本数据
79
- text: '',
80
- id: null
81
- }
66
+ name: "zydx-sketchpad",
67
+ data() {
68
+ return {
69
+ canvas: null,
70
+ strokeWidth: 2, // 线条粗细
71
+ color: '#000', // 线条颜色
72
+ line: null, // 线条
73
+ isDown: false, // 是否按下
74
+ state: null, // 状态
75
+ rect: null, // 矩形
76
+ circle: null, // 圆形
77
+ fontSize: 14, // 字体大小
78
+ setShow: false, // 设置
79
+ strokeData: ['1', '2', '3', '4', '5', '6', '7'], // 画笔数据
80
+ strokeColor: ['#000', '#f00', '#0f0', '#00f', '#f0f', '#ff0', '#0ff'], // 画笔颜色
81
+ textShow: false, // 文本
82
+ textData: ['14', '16', '18', '20', '22', '24', '28', '30'], // 文本数据
83
+ text: '',
84
+ id: null,
85
+ left: 0,
86
+ top: 0,
87
+ isMove: false,
88
+ x: -50,
89
+ y: 0,
90
+ offLeft: 0,
91
+ offTop: 0,
92
+ scrollTop: 0
93
+ }
94
+ },
95
+ props: {
96
+ data: {
97
+ type: Object,
98
+ default: () => {
99
+ }
82
100
  },
83
- props: {
84
- data: {
85
- type: Object,
86
- default: () => {}
87
- },
88
- width: {
89
- type: Number,
90
- default: 800
91
- },
92
- height: {
93
- type: Number,
94
- default: 800
95
- }
101
+ width: {
102
+ type: Number,
103
+ default: 800
96
104
  },
97
- emits: ['save'],
98
- watch: {
99
- data: {
100
- handler(val) {
101
- this.canvas.loadFromJSON(val)
102
- },
103
- deep: true
104
- }
105
+ height: {
106
+ type: Number,
107
+ default: 800
108
+ }
109
+ },
110
+ emits: ['save'],
111
+ watch: {
112
+ data: {
113
+ handler(val) {
114
+ this.canvas.loadFromJSON(val)
115
+ },
116
+ deep: true
117
+ }
118
+ },
119
+ mounted() {
120
+ // 生成随机id
121
+ this.id = Math.random().toString(36).substr(2)
122
+ setTimeout(() => {
123
+ this.init()
124
+ }, 0)
125
+ window.addEventListener('keydown', this.handleKeyEvent)
126
+ this.offLeft = this.$refs.sketchpad.offsetLeft
127
+ this.offTop = this.$refs.sketchpad.offsetTop
128
+ // 监听滚动
129
+ this.throttleHandleScroll()
130
+ window.addEventListener('scroll', this.throttleHandleScroll);
131
+ document.addEventListener('mousemove', (event) => {
132
+ if (!this.isMove) return
133
+ this.x = event.clientX - this.left;
134
+ this.y = event.clientY - this.top;
135
+ })
136
+ },
137
+ beforeDestroy() {
138
+ window.removeEventListener('keydown', this.handleKeyEvent)
139
+ },
140
+ methods: {
141
+ throttleHandleScroll() {
142
+ this.scrollTop = document.documentElement.scrollTop || document.body.scrollTop
143
+ },
144
+ mousedown(event) {
145
+ event.preventDefault()
146
+ //鼠标按下事件
147
+ this.left = event.offsetX + this.offLeft
148
+ this.top = event.offsetY + this.offTop - this.scrollTop
149
+ this.isMove = true
150
+ },
151
+ mouseup() {
152
+ //鼠标松开事件
153
+ this.isMove = false
105
154
  },
106
- mounted() {
107
- // 生成随机id
108
- this.id = Math.random().toString(36).substr(2)
109
- setTimeout(() => {
110
- this.init()
111
- },0)
112
- window.addEventListener('keydown', this.handleKeyEvent)
155
+ sizeTap(v) {
156
+ this.fontSize = Number(v)
113
157
  },
114
- beforeDestroy() {
115
- window.removeEventListener('keydown', this.handleKeyEvent)
158
+ addTextBox() {
159
+ this.state = 'text'
160
+ this.setShow = false
161
+ this.textShow = !this.textShow
116
162
  },
117
- methods: {
118
- sizeTap(v) {
119
- this.fontSize = Number(v)
120
- },
121
- addTextBox() {
122
- this.state = 'text'
123
- this.setShow = false
124
- this.textShow = !this.textShow
125
- },
126
- strokeColTap(v) {
127
- this.color = v
128
- },
129
- strokeTap(v) {
130
- this.strokeWidth = Number(v)
131
- },
132
- set() {
133
- this.textShow = false
134
- this.setShow = !this.setShow
135
- },
136
- init() {
137
- this.canvas = new fabric.Canvas(this.id, {
138
- isDrawingMode: false,
139
- width: this.width,
140
- height: this.height,
141
- });
142
- this.canvas.selectionColor = "rgba(255,255,255,0)";
143
- this.canvas.loadFromJSON(this.data)
144
- },
145
- // 画笔
146
- brush() {
147
- this.state = 'brush'
148
- this.canvas.isDrawingMode = !this.canvas.isDrawingMode
149
- this.canvas.freeDrawingBrush.width = this.strokeWidth
150
- this.canvas.freeDrawingBrush.color = this.color
151
- },
152
- // 直线
153
- addLine() {
154
- this.canvas.isDrawingMode = false
155
- this.state = 'line'
156
- const id = Date.now()
157
- this.canvas.on('mouse:down', (o) => {
158
- if(o.target !== null) return
159
- if(this.state !== 'line') return
160
- this.isDown = true
161
- const pointer = this.canvas.getPointer(o.e)
162
- const points = [pointer.x, pointer.y, pointer.x, pointer.y]
163
- this.line = new fabric.Line(points, {
164
- id: id,
165
- strokeWidth: this.strokeWidth,
166
- fill: this.color,
167
- stroke: this.color,
168
- originX: 'center',
169
- originY: 'center'
170
- })
171
- this.canvas.add(this.line)
172
- })
173
- this.canvas.on('mouse:move', (o) => {
174
- if(this.state !== 'line') return
175
- if (!this.isDown) return
176
- const pointer = this.canvas.getPointer(o.e)
177
- this.line.set({ x2: pointer.x, y2: pointer.y })
178
- this.canvas.renderAll()
179
- })
163
+ strokeColTap(v) {
164
+ this.color = v
165
+ },
166
+ strokeTap(v) {
167
+ this.strokeWidth = Number(v)
168
+ },
169
+ set() {
170
+ this.textShow = false
171
+ this.setShow = !this.setShow
172
+ },
173
+ init() {
174
+ this.canvas = new fabric.Canvas(this.id, {
175
+ isDrawingMode: false,
176
+ width: this.width,
177
+ height: this.height,
178
+ });
179
+ this.canvas.selectionColor = "rgba(255,255,255,0)";
180
+ this.canvas.loadFromJSON(this.data)
181
+ this.y = (this.height / 2) - 203
182
+ },
183
+ // 画笔
184
+ brush() {
185
+ this.state = 'brush'
186
+ this.canvas.isDrawingMode = !this.canvas.isDrawingMode
187
+ this.canvas.freeDrawingBrush.width = this.strokeWidth
188
+ this.canvas.freeDrawingBrush.color = this.color
189
+ },
190
+ // 直线
191
+ addLine() {
192
+ this.canvas.isDrawingMode = false
193
+ this.state = 'line'
194
+ const id = Date.now()
195
+ this.canvas.on('mouse:down', (o) => {
196
+ if (o.target !== null) return
197
+ if (this.state !== 'line') return
198
+ this.isDown = true
199
+ const pointer = this.canvas.getPointer(o.e)
200
+ const points = [pointer.x, pointer.y, pointer.x, pointer.y]
201
+ this.line = new fabric.Line(points, {
202
+ id: id,
203
+ strokeWidth: this.strokeWidth,
204
+ fill: this.color,
205
+ stroke: this.color,
206
+ originX: 'center',
207
+ originY: 'center'
208
+ })
209
+ this.canvas.add(this.line)
210
+ })
211
+ this.canvas.on('mouse:move', (o) => {
212
+ if (this.state !== 'line') return
213
+ if (!this.isDown) return
214
+ const pointer = this.canvas.getPointer(o.e)
215
+ this.line.set({x2: pointer.x, y2: pointer.y})
216
+ this.canvas.renderAll()
217
+ })
180
218
 
181
- this.canvas.on('mouse:up', (o) => {
182
- this.isDown = false
183
- this.line.setCoords()
184
- })
185
- },
186
- // 矩形
187
- rectangle() {
188
- this.canvas.isDrawingMode = false
189
- this.state = 'rectangle'
190
- const id = Date.now()
191
- let origX, origY
192
- this.canvas.on('mouse:down', (o) => {
193
- if(o.target !== null) return
194
- if(this.state !== 'rectangle') return
195
- this.isDown = true
196
- let pointer = this.canvas.getPointer(o.e)
197
- origX = pointer.x
198
- origY = pointer.y
199
- this.rect = new fabric.Rect({
200
- id: id,
201
- left: origX,
202
- top: origY,
203
- originX: 'left',
204
- originY: 'top',
205
- width: pointer.x - origX,
206
- height: pointer.y - origY,
207
- angle: 0,
208
- fill: '',
209
- stroke: this.color,
210
- strokeWidth: this.strokeWidth
211
- })
212
- this.canvas.add(this.rect)
213
- })
214
- this.canvas.on('mouse:move', (o) => {
215
- if(this.state !== 'rectangle') return
216
- if (!this.isDown) return
217
- let pointer = this.canvas.getPointer(o.e)
219
+ this.canvas.on('mouse:up', (o) => {
220
+ this.isDown = false
221
+ this.line.setCoords()
222
+ })
223
+ },
224
+ // 矩形
225
+ rectangle() {
226
+ this.canvas.isDrawingMode = false
227
+ this.state = 'rectangle'
228
+ const id = Date.now()
229
+ let origX, origY
230
+ this.canvas.on('mouse:down', (o) => {
231
+ if (o.target !== null) return
232
+ if (this.state !== 'rectangle') return
233
+ this.isDown = true
234
+ let pointer = this.canvas.getPointer(o.e)
235
+ origX = pointer.x
236
+ origY = pointer.y
237
+ this.rect = new fabric.Rect({
238
+ id: id,
239
+ left: origX,
240
+ top: origY,
241
+ originX: 'left',
242
+ originY: 'top',
243
+ width: pointer.x - origX,
244
+ height: pointer.y - origY,
245
+ angle: 0,
246
+ fill: '',
247
+ stroke: this.color,
248
+ strokeWidth: this.strokeWidth
249
+ })
250
+ this.canvas.add(this.rect)
251
+ })
252
+ this.canvas.on('mouse:move', (o) => {
253
+ if (this.state !== 'rectangle') return
254
+ if (!this.isDown) return
255
+ let pointer = this.canvas.getPointer(o.e)
218
256
 
219
- if (origX > pointer.x) {
220
- this.rect.set({ left: Math.abs(pointer.x) })
221
- }
222
- if (origY > pointer.y) {
223
- this.rect.set({ top: Math.abs(pointer.y) })
224
- }
225
- this.rect.set({ width: Math.abs(origX - pointer.x) })
226
- this.rect.set({ height: Math.abs(origY - pointer.y) })
227
- this.canvas.renderAll()
228
- })
229
- this.canvas.on('mouse:up', (o) => {
230
- this.isDown = false
231
- this.rect.setCoords()
232
- })
233
- },
234
- // 圆形
235
- rotundity() {
236
- this.canvas.isDrawingMode = false
237
- this.state = 'rotundity'
238
- let origX, origY
239
- this.canvas.on('mouse:down', (o) => {
240
- if(o.target !== null) return
241
- if(this.state !== 'rotundity') return
242
- this.isDown = true
243
- let pointer = this.canvas.getPointer(o.e)
244
- origX = pointer.x
245
- origY = pointer.y
246
- this.circle = new fabric.Circle({
247
- left: origX,
248
- top: origY,
249
- originX: 'left',
250
- originY: 'top',
251
- radius: pointer.x - origX,
252
- angle: 0,
253
- fill: '',
254
- stroke: this.color,
255
- strokeWidth: this.strokeWidth
256
- })
257
- this.canvas.add(this.circle)
258
- })
259
- this.canvas.on('mouse:move', (o) => {
260
- if(this.state !== 'rotundity') return
261
- if (!this.isDown) return
262
- let pointer = this.canvas.getPointer(o.e)
263
- let radius =
264
- Math.max(
265
- Math.abs(origY - pointer.y),
266
- Math.abs(origX - pointer.x)
267
- ) / 2
268
- if (radius > this.circle.strokeWidth) {
269
- radius -= this.circle.strokeWidth / 2
270
- }
271
- this.circle.set({ radius: radius })
257
+ if (origX > pointer.x) {
258
+ this.rect.set({left: Math.abs(pointer.x)})
259
+ }
260
+ if (origY > pointer.y) {
261
+ this.rect.set({top: Math.abs(pointer.y)})
262
+ }
263
+ this.rect.set({width: Math.abs(origX - pointer.x)})
264
+ this.rect.set({height: Math.abs(origY - pointer.y)})
265
+ this.canvas.renderAll()
266
+ })
267
+ this.canvas.on('mouse:up', (o) => {
268
+ this.isDown = false
269
+ this.rect.setCoords()
270
+ })
271
+ },
272
+ // 圆形
273
+ rotundity() {
274
+ this.canvas.isDrawingMode = false
275
+ this.state = 'rotundity'
276
+ let origX, origY
277
+ this.canvas.on('mouse:down', (o) => {
278
+ if (o.target !== null) return
279
+ if (this.state !== 'rotundity') return
280
+ this.isDown = true
281
+ let pointer = this.canvas.getPointer(o.e)
282
+ origX = pointer.x
283
+ origY = pointer.y
284
+ this.circle = new fabric.Circle({
285
+ left: origX,
286
+ top: origY,
287
+ originX: 'left',
288
+ originY: 'top',
289
+ radius: pointer.x - origX,
290
+ angle: 0,
291
+ fill: '',
292
+ stroke: this.color,
293
+ strokeWidth: this.strokeWidth
294
+ })
295
+ this.canvas.add(this.circle)
296
+ })
297
+ this.canvas.on('mouse:move', (o) => {
298
+ if (this.state !== 'rotundity') return
299
+ if (!this.isDown) return
300
+ let pointer = this.canvas.getPointer(o.e)
301
+ let radius =
302
+ Math.max(
303
+ Math.abs(origY - pointer.y),
304
+ Math.abs(origX - pointer.x)
305
+ ) / 2
306
+ if (radius > this.circle.strokeWidth) {
307
+ radius -= this.circle.strokeWidth / 2
308
+ }
309
+ this.circle.set({radius: radius})
272
310
 
273
- if (origX > pointer.x) {
274
- this.circle.set({ originX: 'right' })
275
- } else {
276
- this.circle.set({ originX: 'left' })
277
- }
278
- if (origY > pointer.y) {
279
- this.circle.set({ originY: 'bottom' })
280
- } else {
281
- this.circle.set({ originY: 'top' })
282
- }
283
- this.canvas.renderAll()
284
- })
285
- this.canvas.on('mouse:up', () => {
286
- this.isDown = false
287
- this.circle.setCoords()
288
- })
289
- },
290
- // 箭头
291
- arrow() {
292
- const id = Date.now()
293
- const triangle = new fabric.Triangle({
294
- width: 9,
295
- height: 15,
296
- fill: 'black',
297
- left: 150,
298
- top: 137,
299
- angle: 90
300
- })
301
- const line = new fabric.Rect({
302
- left: 100,
303
- top: 140,
304
- width: 40,
305
- height: 3,
306
- fill: 'black',
307
- originX: 'left',
308
- originY: 'top',
309
- centeredRotation: true
310
- })
311
- const arrow = new fabric.Group([line, triangle], {
312
- id: id,
313
- left: this.canvas.width / 2,
314
- top: this.canvas.height / 2,
315
- angle: 0
316
- })
317
- this.canvas.add(arrow)
318
- },
319
- // 文本框
320
- textBox() {
321
- const id = Date.now()
322
- this.textbox = new fabric.Textbox(this.text, {
323
- id: id,
324
- top: 200,
325
- left: 200,
326
- width: 10,
327
- fill: this.color,
328
- fontSize: this.fontSize,
329
- color: this.color,
330
- fontWeight: 400,
331
- lineHeight: 1.5,
332
- fontFamily: '微软雅黑',
333
- textDecoration: 'none',
334
- textAlign: 'left'
335
- })
336
- this.canvas.add(this.textbox)
337
- },
338
- save() {
339
- console.log(this.canvas.toJSON())
340
- this.$emit('save', this.canvas.toJSON())
341
- },
342
- clear() {
343
- this.canvas.clear()
344
- },
345
- handleKeyEvent (e) {
346
- const { key } = e
347
- if (key === 'Backspace' || key === 'Delete') {
348
- const el = this.canvas.getActiveObject()
349
- if(el) this.canvas.remove(el)
350
- }
311
+ if (origX > pointer.x) {
312
+ this.circle.set({originX: 'right'})
313
+ } else {
314
+ this.circle.set({originX: 'left'})
351
315
  }
316
+ if (origY > pointer.y) {
317
+ this.circle.set({originY: 'bottom'})
318
+ } else {
319
+ this.circle.set({originY: 'top'})
320
+ }
321
+ this.canvas.renderAll()
322
+ })
323
+ this.canvas.on('mouse:up', () => {
324
+ this.isDown = false
325
+ this.circle.setCoords()
326
+ })
327
+ },
328
+ // 箭头
329
+ arrow() {
330
+ const id = Date.now()
331
+ const triangle = new fabric.Triangle({
332
+ width: 9,
333
+ height: 15,
334
+ fill: 'black',
335
+ left: 150,
336
+ top: 137,
337
+ angle: 90
338
+ })
339
+ const line = new fabric.Rect({
340
+ left: 100,
341
+ top: 140,
342
+ width: 40,
343
+ height: 3,
344
+ fill: 'black',
345
+ originX: 'left',
346
+ originY: 'top',
347
+ centeredRotation: true
348
+ })
349
+ const arrow = new fabric.Group([line, triangle], {
350
+ id: id,
351
+ left: this.canvas.width / 2,
352
+ top: this.canvas.height / 2,
353
+ angle: 0
354
+ })
355
+ this.canvas.add(arrow)
356
+ },
357
+ // 文本框
358
+ textBox() {
359
+ const id = Date.now()
360
+ this.textbox = new fabric.Textbox(this.text, {
361
+ id: id,
362
+ top: 200,
363
+ left: 200,
364
+ width: 10,
365
+ fill: this.color,
366
+ fontSize: this.fontSize,
367
+ color: this.color,
368
+ fontWeight: 400,
369
+ lineHeight: 1.5,
370
+ fontFamily: '微软雅黑',
371
+ textDecoration: 'none',
372
+ textAlign: 'left'
373
+ })
374
+ this.canvas.add(this.textbox)
375
+ },
376
+ save() {
377
+ console.log(this.canvas.toJSON())
378
+ this.$emit('save', this.canvas.toJSON())
379
+ },
380
+ clear() {
381
+ this.canvas.clear()
382
+ },
383
+ handleKeyEvent(e) {
384
+ const {key} = e
385
+ if (key === 'Backspace' || key === 'Delete') {
386
+ const el = this.canvas.getActiveObject()
387
+ if (el) this.canvas.remove(el)
388
+ }
352
389
  }
390
+ }
353
391
  }
354
392
  </script>
355
393
 
356
394
  <style scoped>
357
- .sketchpad{
358
- position: relative;
395
+ .sketchpad {
396
+ position: relative;
359
397
  }
360
- .tool{
361
- position: absolute;
362
- top: 50%;
363
- left: -55px;
364
- z-index: 1;
365
- width: 50px;
366
- padding: 15px;
367
- border-radius: 10px;
368
- box-shadow: 0 0 5px 3px rgba(0,0,0,0.3);
369
- box-sizing: border-box;
370
- background: #fff;
371
- margin-top: -200px;
398
+
399
+ .tool {
400
+ position: absolute;
401
+ top: 0;
402
+ left: 0;
403
+ z-index: 1;
404
+ width: 50px;
405
+ padding: 15px;
406
+ border-radius: 10px;
407
+ box-shadow: 0 0 5px 3px rgba(0, 0, 0, 0.3);
408
+ box-sizing: border-box;
409
+ background: #fff;
410
+ transition-property: transform;
411
+ transition-duration: 0ms;
412
+ transition-timing-function: linear;
413
+ transition-delay: 0ms;
414
+ transform: translate(0px, 0px);
415
+ cursor: move;
416
+ user-select: none;
372
417
  }
373
- .tool-list{
374
- width: 100%;
375
- margin-bottom: 20px;
376
- cursor: pointer;
377
- position: relative;
418
+
419
+ .tool-list {
420
+ width: 100%;
421
+ margin-bottom: 20px;
422
+ cursor: pointer;
423
+ position: relative;
378
424
  }
379
- .tool-list:last-child{
380
- margin-bottom: 0;
425
+
426
+ .tool-list:last-child {
427
+ margin-bottom: 0;
381
428
  }
382
- .tool-list img{
383
- width: 100%;
429
+
430
+ .tool-list img {
431
+ width: 100%;
384
432
  }
385
- .set{
386
- position: absolute;
387
- top: 0;
388
- left: 40px;
389
- width: 280px;
390
- background-color: #fff;
391
- border-radius: 10px;
392
- box-shadow: 0 0 5px 3px rgba(0,0,0,0.3);
393
- padding: 10px;
394
- z-index: 1;
433
+
434
+ .set {
435
+ position: absolute;
436
+ top: 0;
437
+ left: 40px;
438
+ width: 280px;
439
+ background-color: #fff;
440
+ border-radius: 10px;
441
+ box-shadow: 0 0 5px 3px rgba(0, 0, 0, 0.3);
442
+ padding: 10px;
443
+ z-index: 1;
395
444
  }
396
- .set-list{
397
- padding: 5px 0;
398
- font-size: 15px;
445
+
446
+ .set-list {
447
+ padding: 5px 0;
448
+ font-size: 15px;
399
449
  }
400
- .set-list:after{
401
- content: '';
402
- display: block;
403
- clear: both;
450
+
451
+ .set-list:after {
452
+ content: '';
453
+ display: block;
454
+ clear: both;
404
455
  }
405
- .set-list span{
406
- margin-right: 10px;
407
- float: left;
456
+
457
+ .set-list span {
458
+ margin-right: 10px;
459
+ float: left;
408
460
  }
409
- .set-list em{
410
- font-style: normal;
411
- font-size: 15px;
412
- width: 16px;
413
- display: inline-block;
414
- margin-right: 10px;
415
- text-align: center;
461
+
462
+ .set-list em {
463
+ font-style: normal;
464
+ font-size: 15px;
465
+ width: 16px;
466
+ display: inline-block;
467
+ margin-right: 10px;
468
+ text-align: center;
416
469
  }
417
- .set-list em:hover{
418
- color: #5daf34;
470
+
471
+ .set-list em:hover {
472
+ color: #5daf34;
419
473
  }
420
- .set-list i{
421
- display: inline-block;
422
- width: 16px;
423
- height: 16px;
424
- background-color: #000;
425
- margin: 2px 10px 0 0;
426
- float: left;
474
+
475
+ .set-list i {
476
+ display: inline-block;
477
+ width: 16px;
478
+ height: 16px;
479
+ background-color: #000;
480
+ margin: 2px 10px 0 0;
481
+ float: left;
427
482
  }
428
- .set-list input{
429
- width: calc(100% - 60px);
430
- height: 22px;
431
- border: 1px solid #ccc;
432
- border-radius: 5px;
433
- padding: 0 10px;
434
- box-sizing: border-box;
435
- float: left;
483
+
484
+ .set-list input {
485
+ width: calc(100% - 60px);
486
+ height: 22px;
487
+ border: 1px solid #ccc;
488
+ border-radius: 5px;
489
+ padding: 0 10px;
490
+ box-sizing: border-box;
491
+ float: left;
436
492
  }
437
- .but{
438
- margin-left: 5px;
439
- font-size: 12px;
440
- background-color: transparent;
441
- border: 1px solid #000;
442
- border-radius: 3px;
443
- padding: 2px 5px;
444
- cursor: pointer;
445
- min-width: 60px;
446
- height: 21px;
447
- margin-right: 20px;
493
+
494
+ .but {
495
+ margin-left: 5px;
496
+ font-size: 12px;
497
+ background-color: transparent;
498
+ border: 1px solid #000;
499
+ border-radius: 3px;
500
+ padding: 2px 5px;
501
+ cursor: pointer;
502
+ min-width: 60px;
503
+ height: 21px;
504
+ margin-right: 20px;
448
505
  }
449
- .set-right{
450
- text-align: right;
506
+
507
+ .set-right {
508
+ text-align: right;
451
509
  }
452
510
  </style>
@@ -60,8 +60,10 @@
60
60
  </div>
61
61
  <div v-if="item.alist" class="subject-html" v-show="item.open">
62
62
  <div v-for="(it,ind) in item.alist">
63
- <div class="subject-html-title">{{ titleText }}{{ ind + 1 }}</div>
64
- <div class="subject-html-cont" v-html="it.annexContent"></div>
63
+ <div v-if="it.annexType === '0'">
64
+ <div class="subject-html-title">{{ titleText }}{{ ind + 1 }}</div>
65
+ <div class="subject-html-cont" v-html="it.annexContent"></div>
66
+ </div>
65
67
  </div>
66
68
  </div>
67
69
  <div class="choice" v-if="item.testKey" v-show="item.open">
package/src/index.js CHANGED
@@ -79,7 +79,7 @@ function install(app) {
79
79
  }
80
80
 
81
81
  export default {
82
- version: '1.32.258',
82
+ version: '1.32.260',
83
83
  install,
84
84
  Calendar,
85
85
  Message,