zydx-plus 1.32.299 → 1.32.300
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 +60 -54
- package/src/index.js +1 -1
package/package.json
CHANGED
|
@@ -131,6 +131,8 @@ import * as PdfJs from 'pdfjs-dist/legacy/build/pdf.js' // 注意导入的写法
|
|
|
131
131
|
PdfJs.GlobalWorkerOptions.workerSrc = require('pdfjs-dist/build/pdf.worker.entry')
|
|
132
132
|
const jsdelivr = '/zydx/static/cmaps/'
|
|
133
133
|
|
|
134
|
+
let pdfs = null
|
|
135
|
+
|
|
134
136
|
export default {
|
|
135
137
|
name: "zydx-flip",
|
|
136
138
|
data() {
|
|
@@ -188,7 +190,7 @@ export default {
|
|
|
188
190
|
textHeight: 0,
|
|
189
191
|
textDownX: 0,
|
|
190
192
|
textDownY: 0,
|
|
191
|
-
textMoveStart: false
|
|
193
|
+
textMoveStart: false
|
|
192
194
|
}
|
|
193
195
|
},
|
|
194
196
|
props: {
|
|
@@ -241,7 +243,7 @@ export default {
|
|
|
241
243
|
},
|
|
242
244
|
source: {
|
|
243
245
|
handler: function () {
|
|
244
|
-
this.
|
|
246
|
+
this.sourceUrl()
|
|
245
247
|
},
|
|
246
248
|
deep: true,
|
|
247
249
|
immediate: true
|
|
@@ -936,6 +938,7 @@ export default {
|
|
|
936
938
|
}
|
|
937
939
|
},
|
|
938
940
|
flipLeft(e, v) {
|
|
941
|
+
console.log(e)
|
|
939
942
|
if (e > this.pdfPages) {
|
|
940
943
|
this.pageIndex = this.pdfPages
|
|
941
944
|
return
|
|
@@ -952,6 +955,7 @@ export default {
|
|
|
952
955
|
}
|
|
953
956
|
},
|
|
954
957
|
flipRight(e, v) {
|
|
958
|
+
console.log(e)
|
|
955
959
|
if (e < 1) {
|
|
956
960
|
this.pageIndex = 1
|
|
957
961
|
return
|
|
@@ -967,65 +971,67 @@ export default {
|
|
|
967
971
|
})
|
|
968
972
|
}
|
|
969
973
|
},
|
|
970
|
-
|
|
971
|
-
this.mouse()
|
|
974
|
+
sourceUrl() {
|
|
972
975
|
if (this.source === '' || this.source === undefined || this.source === null) return
|
|
973
976
|
let that = this
|
|
974
|
-
|
|
975
|
-
if (that.imgArr[that.pageIndex - 1] !== undefined) {
|
|
976
|
-
that.oneShow = that.pageIndex !== 1
|
|
977
|
-
}
|
|
977
|
+
that.loading = true
|
|
978
978
|
const loadingTask = PdfJs.getDocument({
|
|
979
|
-
url:
|
|
979
|
+
url: that.source,
|
|
980
980
|
cMapUrl: jsdelivr,
|
|
981
981
|
cMapPacked: true
|
|
982
982
|
})
|
|
983
983
|
loadingTask.promise.then((pdf) => {
|
|
984
|
+
pdfs = pdf
|
|
984
985
|
that.pdfPages = pdf.numPages // 获取pdf文件的总页数
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
986
|
+
that.readPdf(pdf)
|
|
987
|
+
})
|
|
988
|
+
},
|
|
989
|
+
readPdf() {
|
|
990
|
+
let that = this
|
|
991
|
+
this.mouse()
|
|
992
|
+
pdfs.getPage(that.pageIndex).then(function (page) {
|
|
993
|
+
let canvas = document.getElementById(that.id)
|
|
994
|
+
let canvas2 = document.getElementById(`${that.id}2`)
|
|
995
|
+
that.ctx = canvas.getContext('2d');
|
|
996
|
+
let ctx2 = canvas2.getContext('2d');
|
|
997
|
+
let viewport = page.getViewport({scale: that.scales})
|
|
998
|
+
canvas.width = viewport.width * that.sratio
|
|
999
|
+
canvas.height = viewport.height * that.sratio
|
|
1000
|
+
canvas.style.width = viewport.width + 'px'
|
|
1001
|
+
canvas.style.height = viewport.height + 'px'
|
|
1002
|
+
canvas2.width = viewport.width * that.sratio
|
|
1003
|
+
canvas2.height = viewport.height * that.sratio
|
|
1004
|
+
canvas2.style.width = viewport.width + 'px'
|
|
1005
|
+
canvas2.style.height = viewport.height + 'px'
|
|
1006
|
+
that.canvasStyle = {
|
|
1007
|
+
width: viewport.width + 'px',
|
|
1008
|
+
height: viewport.height + 'px',
|
|
1009
|
+
marginLeft: -(viewport.width / 2) + 'px',
|
|
1010
|
+
widthCanvas: viewport.width * that.sratio,
|
|
1011
|
+
heightCanvas: viewport.height * that.sratio
|
|
1012
|
+
}
|
|
1013
|
+
let renderContext = {
|
|
1014
|
+
canvasContext: ctx2,
|
|
1015
|
+
viewport: viewport,
|
|
1016
|
+
transform: [2, 0, 0, 2, 0, 0] //这里会进行放大,解决模糊问题
|
|
1017
|
+
}
|
|
1018
|
+
page.render(renderContext)
|
|
1019
|
+
that.loading = false
|
|
1020
|
+
if (that.oneIndex === 'right') {
|
|
1021
|
+
that.flipRights = true
|
|
1022
|
+
that.flipLefts = false
|
|
1023
|
+
} else {
|
|
1024
|
+
that.flipRights = false
|
|
1025
|
+
that.flipLefts = true
|
|
1026
|
+
}
|
|
1027
|
+
// 获取canvas的base64数据
|
|
1028
|
+
setTimeout(() => {
|
|
1029
|
+
that.flipRights = false
|
|
1030
|
+
that.flipLefts = false
|
|
1031
|
+
that.oneShow = false
|
|
1032
|
+
that.imgArr[that.pageIndex] = canvas2.toDataURL('image/jpeg', 1)
|
|
1033
|
+
that.processing()
|
|
1034
|
+
}, 1000)
|
|
1029
1035
|
})
|
|
1030
1036
|
}
|
|
1031
1037
|
}
|
|
@@ -1251,7 +1257,7 @@ export default {
|
|
|
1251
1257
|
display: inline-block;
|
|
1252
1258
|
margin: 0 auto;
|
|
1253
1259
|
position: relative;
|
|
1254
|
-
|
|
1260
|
+
//cursor: none;
|
|
1255
1261
|
}
|
|
1256
1262
|
|
|
1257
1263
|
.but-wrap {
|