zydx-plus 1.35.488 → 1.35.489
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 +1 -1
- package/src/components/flip/src/flip.vue +125 -113
- package/src/index.js +1 -1
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<div class="docView">
|
|
2
|
+
<div class="docView" @mouseleave="mouseUpTest" @mouseup="mouseUpTest">
|
|
3
3
|
<div class="full-screen" v-if="false">
|
|
4
4
|
<div class="full-screen-img" @click.stop="fullScreen">
|
|
5
5
|
<!-- <div class="full-screen-title" style="" v-if="showText">全屏查看</div>-->
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
<div>
|
|
22
22
|
<div class="book" ref="book">
|
|
23
23
|
<div class="pages">
|
|
24
|
-
<div class="wrap-box" ref="wrap-box"
|
|
24
|
+
<div class="wrap-box" ref="wrap-box" v-show="doublePage">
|
|
25
25
|
<div class="wrap wrap-block" :ref="`wrap-${item.id}`" v-for="(item,index) in pageInfoArr" :key="index">
|
|
26
26
|
<div class="wrap-can" v-show="!loading" ref="wrapCanBox">
|
|
27
27
|
<canvas @click.stop="turnText" class="wrap-can-one" @mousedown.stop="mouseDown"
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
</div>
|
|
46
46
|
</div>
|
|
47
47
|
</div>
|
|
48
|
-
<div class="wrap" ref="wrap" v-
|
|
48
|
+
<div class="wrap" ref="wrap" v-show="!doublePage">
|
|
49
49
|
<div class="wrap-can" v-show="!loading" ref="wrapCan">
|
|
50
50
|
<canvas @click.stop="turnText" class="wrap-can-one" @mousedown.stop="mouseDown"
|
|
51
51
|
@mousemove.stop="mouseMove" :id="`${id}`"></canvas>
|
|
@@ -105,7 +105,7 @@ import {debounce} from '../../utils'
|
|
|
105
105
|
|
|
106
106
|
PdfJs.GlobalWorkerOptions.workerSrc = require('pdfjs-dist/build/pdf.worker.entry')
|
|
107
107
|
|
|
108
|
-
let pdfs = null
|
|
108
|
+
let pdfs = null;
|
|
109
109
|
|
|
110
110
|
export default {
|
|
111
111
|
name: "zydx-flip",
|
|
@@ -292,15 +292,15 @@ export default {
|
|
|
292
292
|
},
|
|
293
293
|
emits: ['flip'],
|
|
294
294
|
mounted() {
|
|
295
|
-
if(!this.doublePage){
|
|
295
|
+
if (!this.doublePage) {
|
|
296
296
|
this.id = 'canvas-wrap' + this.generateUniqueKey()
|
|
297
297
|
}
|
|
298
298
|
window.addEventListener('keydown', this.handleKeyEvent)
|
|
299
299
|
// 在画板以外松开鼠标后冻结画笔
|
|
300
|
-
document.onmouseup = () => {
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
}
|
|
300
|
+
// document.onmouseup = () => {
|
|
301
|
+
// if (this.isDrawing || this.checkDrawing) this.mouseUp()
|
|
302
|
+
// this.textMoveStart = false
|
|
303
|
+
// }
|
|
304
304
|
this.setResizeObserver()
|
|
305
305
|
},
|
|
306
306
|
beforeDestroy() {
|
|
@@ -308,22 +308,26 @@ export default {
|
|
|
308
308
|
this.cancelResizeObserver()
|
|
309
309
|
},
|
|
310
310
|
methods: {
|
|
311
|
+
mouseUpTest(){
|
|
312
|
+
if (this.isDrawing || this.checkDrawing) this.mouseUp()
|
|
313
|
+
this.textMoveStart = false
|
|
314
|
+
},
|
|
311
315
|
setResizeObserver() {
|
|
312
|
-
setTimeout(()=>{
|
|
316
|
+
setTimeout(() => {
|
|
313
317
|
const el = this.$refs.book;
|
|
314
|
-
let resizeTimer
|
|
318
|
+
let resizeTimer;
|
|
315
319
|
this.resizeObserver = new ResizeObserver(() => {
|
|
316
320
|
clearTimeout(resizeTimer);
|
|
317
321
|
resizeTimer = setTimeout(() => {
|
|
318
|
-
if(this.doublePage){
|
|
322
|
+
if (this.doublePage) {
|
|
319
323
|
this.readDoublePdf()
|
|
320
|
-
}else {
|
|
324
|
+
} else {
|
|
321
325
|
this.readPdf()
|
|
322
326
|
}
|
|
323
327
|
}, 150); // 根据需求调整延迟时间
|
|
324
328
|
});
|
|
325
329
|
this.resizeObserver.observe(el);
|
|
326
|
-
},300)
|
|
330
|
+
}, 300)
|
|
327
331
|
},
|
|
328
332
|
cancelResizeObserver() {
|
|
329
333
|
const el = this.$refs.book;
|
|
@@ -333,16 +337,16 @@ export default {
|
|
|
333
337
|
this.$emit('showPen', true)
|
|
334
338
|
// this.isDraw = true
|
|
335
339
|
},
|
|
336
|
-
changeView(){
|
|
337
|
-
this.$emit('changeViewDoublePage'
|
|
338
|
-
setTimeout(()=>{
|
|
340
|
+
changeView() {
|
|
341
|
+
this.$emit('changeViewDoublePage', !this.doublePage)
|
|
342
|
+
setTimeout(() => {
|
|
339
343
|
this.doublePage = !this.doublePage
|
|
340
|
-
if(this.doublePage){
|
|
344
|
+
if (this.doublePage) {
|
|
341
345
|
this.$emit('showPen', false)
|
|
342
346
|
}
|
|
343
|
-
},500)
|
|
347
|
+
}, 500)
|
|
344
348
|
},
|
|
345
|
-
fullScreen(){
|
|
349
|
+
fullScreen() {
|
|
346
350
|
window.open(this.source)
|
|
347
351
|
},
|
|
348
352
|
colorTap(v) {
|
|
@@ -614,13 +618,14 @@ export default {
|
|
|
614
618
|
}
|
|
615
619
|
},
|
|
616
620
|
mouseDown(e) {
|
|
617
|
-
if(this.doublePage){
|
|
621
|
+
if (this.doublePage) {
|
|
618
622
|
return;
|
|
619
623
|
}
|
|
620
624
|
this.setShow = false
|
|
621
625
|
e = e || event
|
|
622
626
|
e.preventDefault()
|
|
623
627
|
if (this.state === null || this.state === 'del') {
|
|
628
|
+
this.$emit('mouseClick')
|
|
624
629
|
this.checkDrawing = true
|
|
625
630
|
this.checkDown(e)
|
|
626
631
|
return
|
|
@@ -644,7 +649,7 @@ export default {
|
|
|
644
649
|
},
|
|
645
650
|
// 鼠标移动
|
|
646
651
|
mouseMove(e) {
|
|
647
|
-
if(this.doublePage){
|
|
652
|
+
if (this.doublePage) {
|
|
648
653
|
return;
|
|
649
654
|
}
|
|
650
655
|
e = e || event
|
|
@@ -1131,9 +1136,9 @@ export default {
|
|
|
1131
1136
|
this.pageIndex = e
|
|
1132
1137
|
}
|
|
1133
1138
|
this.oneIndex = 'right'
|
|
1134
|
-
if(this.doublePage){
|
|
1139
|
+
if (this.doublePage) {
|
|
1135
1140
|
this.readDoublePdf()
|
|
1136
|
-
}else {
|
|
1141
|
+
} else {
|
|
1137
1142
|
this.readPdf()
|
|
1138
1143
|
}
|
|
1139
1144
|
if (!v) {
|
|
@@ -1151,9 +1156,9 @@ export default {
|
|
|
1151
1156
|
this.pageIndex = e
|
|
1152
1157
|
}
|
|
1153
1158
|
this.oneIndex = 'left'
|
|
1154
|
-
if(this.doublePage){
|
|
1159
|
+
if (this.doublePage) {
|
|
1155
1160
|
this.readDoublePdf()
|
|
1156
|
-
}else {
|
|
1161
|
+
} else {
|
|
1157
1162
|
this.readPdf()
|
|
1158
1163
|
}
|
|
1159
1164
|
if (!v) {
|
|
@@ -1176,9 +1181,9 @@ export default {
|
|
|
1176
1181
|
pdfs = pdf
|
|
1177
1182
|
that.pdfPages = pdf.numPages // 获取pdf文件的总页数
|
|
1178
1183
|
that.$nextTick(() => {
|
|
1179
|
-
if(that.doublePage){
|
|
1184
|
+
if (that.doublePage) {
|
|
1180
1185
|
that.readDoublePdf(pdf)
|
|
1181
|
-
}else {
|
|
1186
|
+
} else {
|
|
1182
1187
|
that.readPdf(pdf)
|
|
1183
1188
|
}
|
|
1184
1189
|
})
|
|
@@ -1190,75 +1195,21 @@ export default {
|
|
|
1190
1195
|
})
|
|
1191
1196
|
})
|
|
1192
1197
|
},
|
|
1193
|
-
readPdf:debounce(function (){
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
const hei = wid / sc
|
|
1207
|
-
canvas.width = wid * that.sratio
|
|
1208
|
-
canvas.height = hei * that.sratio
|
|
1209
|
-
canvas.style.width = wid + 'px'
|
|
1210
|
-
canvas.style.height = hei + 'px'
|
|
1211
|
-
canvas2.width = wid * that.sratio
|
|
1212
|
-
canvas2.height = hei * that.sratio
|
|
1213
|
-
canvas2.style.width = wid + 'px'
|
|
1214
|
-
canvas2.style.height = hei + 'px'
|
|
1215
|
-
that.canvasStyle = {
|
|
1216
|
-
width: wid + 'px',
|
|
1217
|
-
height: hei + 'px',
|
|
1218
|
-
marginLeft: -(wid / 2) + 'px',
|
|
1219
|
-
widthCanvas: wid * that.sratio,
|
|
1220
|
-
heightCanvas: hei * that.sratio
|
|
1221
|
-
}
|
|
1222
|
-
let renderContext = {
|
|
1223
|
-
canvasContext: ctx2,
|
|
1224
|
-
viewport: viewport,
|
|
1225
|
-
transform: [2, 0, 0, 2, 0, 0] //这里会进行放大,解决模糊问题
|
|
1226
|
-
}
|
|
1227
|
-
page.render(renderContext)
|
|
1228
|
-
that.loading = false
|
|
1229
|
-
if (that.oneIndex === 'right') {
|
|
1230
|
-
that.flipRights = true
|
|
1231
|
-
that.flipLefts = false
|
|
1232
|
-
} else {
|
|
1233
|
-
that.flipRights = false
|
|
1234
|
-
that.flipLefts = true
|
|
1235
|
-
}
|
|
1236
|
-
// 获取canvas的base64数据
|
|
1237
|
-
setTimeout(() => {
|
|
1238
|
-
that.flipRights = false
|
|
1239
|
-
that.flipLefts = false
|
|
1240
|
-
that.oneShow = false
|
|
1241
|
-
that.imgArr = canvas2.toDataURL('image/jpeg', 1)
|
|
1242
|
-
that.processing()
|
|
1243
|
-
}, 1000)
|
|
1244
|
-
})
|
|
1245
|
-
},200),
|
|
1246
|
-
readDoublePdf:debounce(function (){
|
|
1247
|
-
let that = this
|
|
1248
|
-
that.mouse()
|
|
1249
|
-
that.$nextTick(()=>{
|
|
1250
|
-
that.pageInfoArr.forEach((item,index)=>{
|
|
1251
|
-
pdfs.getPage(index+1).then(function (page) {
|
|
1252
|
-
let canvas = document.getElementById(item.id)
|
|
1253
|
-
let canvas2 = document.getElementById(`${item.id}2`)
|
|
1254
|
-
item.ctx = canvas.getContext('2d');
|
|
1255
|
-
item.ctx2 = canvas2.getContext('2d');
|
|
1256
|
-
let wrapBoxWidth = that.$refs['wrap-box'].offsetWidth
|
|
1257
|
-
// let newScale= wrapBoxWidth/(wrapBoxWidth-(wrapBoxWidth*0.1*2))
|
|
1258
|
-
let newScale=(wrapBoxWidth/846)*(wrapBoxWidth/(wrapBoxWidth-(wrapBoxWidth*0.115*2)))
|
|
1259
|
-
let viewport = page.getViewport({scale: newScale/2})//
|
|
1198
|
+
readPdf: debounce(function () {
|
|
1199
|
+
setTimeout(() => {
|
|
1200
|
+
let that = this
|
|
1201
|
+
that.mouse()
|
|
1202
|
+
that.$nextTick(() => {
|
|
1203
|
+
pdfs.getPage(that.pageIndex).then(function (page) {
|
|
1204
|
+
let canvas = document.getElementById(`${that.id}`)
|
|
1205
|
+
let canvas2 = document.getElementById(`${that.id}2`)
|
|
1206
|
+
that.ctx = canvas.getContext('2d');
|
|
1207
|
+
let ctx2 = canvas2.getContext('2d');
|
|
1208
|
+
that.boxWidth = that.$refs.wrap.offsetWidth
|
|
1209
|
+
that.scales = (that.boxWidth / 846) * (that.boxWidth / (that.boxWidth - (that.boxWidth * 0.115 * 2)))
|
|
1210
|
+
let viewport = page.getViewport({scale: that.scales})
|
|
1260
1211
|
const sc = viewport.width / viewport.height
|
|
1261
|
-
const wid = that.$refs
|
|
1212
|
+
const wid = that.$refs.wrap.offsetWidth - 10
|
|
1262
1213
|
const hei = wid / sc
|
|
1263
1214
|
canvas.width = wid * that.sratio
|
|
1264
1215
|
canvas.height = hei * that.sratio
|
|
@@ -1276,9 +1227,9 @@ export default {
|
|
|
1276
1227
|
heightCanvas: hei * that.sratio
|
|
1277
1228
|
}
|
|
1278
1229
|
let renderContext = {
|
|
1279
|
-
canvasContext:
|
|
1230
|
+
canvasContext: ctx2,
|
|
1280
1231
|
viewport: viewport,
|
|
1281
|
-
transform: [2,0,0,2,0,0] //这里会进行放大,解决模糊问题
|
|
1232
|
+
transform: [2, 0, 0, 2, 0, 0] //这里会进行放大,解决模糊问题
|
|
1282
1233
|
}
|
|
1283
1234
|
page.render(renderContext)
|
|
1284
1235
|
that.loading = false
|
|
@@ -1294,14 +1245,74 @@ export default {
|
|
|
1294
1245
|
that.flipRights = false
|
|
1295
1246
|
that.flipLefts = false
|
|
1296
1247
|
that.oneShow = false
|
|
1297
|
-
that.
|
|
1248
|
+
that.imgArr = canvas2.toDataURL('image/jpeg', 1)
|
|
1298
1249
|
that.processing()
|
|
1299
1250
|
}, 1000)
|
|
1300
1251
|
})
|
|
1301
1252
|
})
|
|
1302
|
-
})
|
|
1303
|
-
},200),
|
|
1304
|
-
|
|
1253
|
+
}, 200)
|
|
1254
|
+
}, 200),
|
|
1255
|
+
readDoublePdf: debounce(function () {
|
|
1256
|
+
setTimeout(() => {
|
|
1257
|
+
let that = this
|
|
1258
|
+
that.mouse()
|
|
1259
|
+
that.$nextTick(() => {
|
|
1260
|
+
that.pageInfoArr.forEach((item, index) => {
|
|
1261
|
+
pdfs.getPage(index + 1).then(function (page) {
|
|
1262
|
+
let canvas = document.getElementById(item.id)
|
|
1263
|
+
let canvas2 = document.getElementById(`${item.id}2`)
|
|
1264
|
+
item.ctx = canvas.getContext('2d');
|
|
1265
|
+
item.ctx2 = canvas2.getContext('2d');
|
|
1266
|
+
let wrapBoxWidth = that.$refs['wrap-box'].offsetWidth
|
|
1267
|
+
// let newScale= wrapBoxWidth/(wrapBoxWidth-(wrapBoxWidth*0.1*2))
|
|
1268
|
+
let newScale = (wrapBoxWidth / 846) * (wrapBoxWidth / (wrapBoxWidth - (wrapBoxWidth * 0.115 * 2)))
|
|
1269
|
+
let viewport = page.getViewport({scale: newScale / 2})//
|
|
1270
|
+
const sc = viewport.width / viewport.height
|
|
1271
|
+
const wid = that.$refs[`wrap-${item.id}`][0].offsetWidth - 15
|
|
1272
|
+
const hei = wid / sc
|
|
1273
|
+
canvas.width = wid * that.sratio
|
|
1274
|
+
canvas.height = hei * that.sratio
|
|
1275
|
+
canvas.style.width = wid + 'px'
|
|
1276
|
+
canvas.style.height = hei + 'px'
|
|
1277
|
+
canvas2.width = wid * that.sratio
|
|
1278
|
+
canvas2.height = hei * that.sratio
|
|
1279
|
+
canvas2.style.width = wid + 'px'
|
|
1280
|
+
canvas2.style.height = hei + 'px'
|
|
1281
|
+
that.canvasStyle = {
|
|
1282
|
+
width: wid + 'px',
|
|
1283
|
+
height: hei + 'px',
|
|
1284
|
+
marginLeft: -(wid / 2) + 'px',
|
|
1285
|
+
widthCanvas: wid * that.sratio,
|
|
1286
|
+
heightCanvas: hei * that.sratio
|
|
1287
|
+
}
|
|
1288
|
+
let renderContext = {
|
|
1289
|
+
canvasContext: item.ctx2,
|
|
1290
|
+
viewport: viewport,
|
|
1291
|
+
transform: [2, 0, 0, 2, 0, 0] //这里会进行放大,解决模糊问题
|
|
1292
|
+
}
|
|
1293
|
+
page.render(renderContext)
|
|
1294
|
+
that.loading = false
|
|
1295
|
+
if (that.oneIndex === 'right') {
|
|
1296
|
+
that.flipRights = true
|
|
1297
|
+
that.flipLefts = false
|
|
1298
|
+
} else {
|
|
1299
|
+
that.flipRights = false
|
|
1300
|
+
that.flipLefts = true
|
|
1301
|
+
}
|
|
1302
|
+
// 获取canvas的base64数据
|
|
1303
|
+
setTimeout(() => {
|
|
1304
|
+
that.flipRights = false
|
|
1305
|
+
that.flipLefts = false
|
|
1306
|
+
that.oneShow = false
|
|
1307
|
+
that.doubleImgArr.push(canvas2.toDataURL('image/jpeg', 1))
|
|
1308
|
+
that.processing()
|
|
1309
|
+
}, 1000)
|
|
1310
|
+
})
|
|
1311
|
+
})
|
|
1312
|
+
})
|
|
1313
|
+
}, 200)
|
|
1314
|
+
}, 200),
|
|
1315
|
+
generateUniqueKey() {
|
|
1305
1316
|
// Math.random().toString(36).substr(2)
|
|
1306
1317
|
return `${new Date().getTime()}${Math.random().toString(36).substr(2)}`;
|
|
1307
1318
|
}
|
|
@@ -1372,7 +1383,7 @@ export default {
|
|
|
1372
1383
|
border: 1px solid #cccccc;
|
|
1373
1384
|
overflow: hidden;
|
|
1374
1385
|
/*box-shadow: 0 0 10px rgba(0, 0, 0, 0.25);*/
|
|
1375
|
-
/*cursor: none;*/
|
|
1386
|
+
/*cursor: none;*/
|
|
1376
1387
|
}
|
|
1377
1388
|
|
|
1378
1389
|
.wrap-can img {
|
|
@@ -1459,7 +1470,7 @@ export default {
|
|
|
1459
1470
|
overflow-y: auto;*/
|
|
1460
1471
|
}
|
|
1461
1472
|
|
|
1462
|
-
.book::-webkit-scrollbar{
|
|
1473
|
+
.book::-webkit-scrollbar {
|
|
1463
1474
|
display: none;
|
|
1464
1475
|
}
|
|
1465
1476
|
|
|
@@ -1518,28 +1529,28 @@ export default {
|
|
|
1518
1529
|
}
|
|
1519
1530
|
}
|
|
1520
1531
|
|
|
1521
|
-
.wrap-box{
|
|
1532
|
+
.wrap-box {
|
|
1522
1533
|
display: flex;
|
|
1523
1534
|
flex-flow: row wrap;
|
|
1524
1535
|
justify-content: space-between;
|
|
1525
1536
|
}
|
|
1526
1537
|
|
|
1527
|
-
.wrap-box
|
|
1538
|
+
.wrap-box > .wrap {
|
|
1528
1539
|
width: 50%;
|
|
1529
1540
|
}
|
|
1530
1541
|
|
|
1531
|
-
div{
|
|
1542
|
+
div {
|
|
1532
1543
|
box-sizing: border-box;
|
|
1533
1544
|
}
|
|
1534
1545
|
|
|
1535
|
-
.full-screen{
|
|
1546
|
+
.full-screen {
|
|
1536
1547
|
position: absolute;
|
|
1537
1548
|
top: 20px;
|
|
1538
1549
|
right: -20px;
|
|
1539
1550
|
z-index: 100;
|
|
1540
1551
|
}
|
|
1541
1552
|
|
|
1542
|
-
.full-screen
|
|
1553
|
+
.full-screen > .full-screen-img {
|
|
1543
1554
|
display: flex;
|
|
1544
1555
|
flex-direction: row;
|
|
1545
1556
|
justify-content: flex-end;
|
|
@@ -1547,12 +1558,13 @@ div{
|
|
|
1547
1558
|
margin-bottom: 10px;
|
|
1548
1559
|
}
|
|
1549
1560
|
|
|
1550
|
-
.full-screen-title{
|
|
1561
|
+
.full-screen-title {
|
|
1551
1562
|
width: 100%;
|
|
1552
1563
|
white-space: nowrap;
|
|
1553
1564
|
overflow: hidden;
|
|
1554
|
-
animation:span-animation 0.3s linear;
|
|
1565
|
+
animation: span-animation 0.3s linear;
|
|
1555
1566
|
}
|
|
1567
|
+
|
|
1556
1568
|
@keyframes span-animation {
|
|
1557
1569
|
0% {
|
|
1558
1570
|
width: 0;
|
|
@@ -1562,9 +1574,9 @@ div{
|
|
|
1562
1574
|
}
|
|
1563
1575
|
}
|
|
1564
1576
|
|
|
1565
|
-
.full-screen-img>img{
|
|
1577
|
+
.full-screen-img > img {
|
|
1566
1578
|
width: 20px;
|
|
1567
1579
|
height: 20px;
|
|
1568
|
-
/*margin-left: 5px;*/
|
|
1580
|
+
/*margin-left: 5px;*/
|
|
1569
1581
|
}
|
|
1570
1582
|
</style>
|