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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zydx-plus",
3
- "version": "1.32.299",
3
+ "version": "1.32.300",
4
4
  "description": "Vue.js",
5
5
  "main": "src/index.js",
6
6
  "files": [
@@ -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.readPdf()
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
- readPdf(n) {
971
- this.mouse()
974
+ sourceUrl() {
972
975
  if (this.source === '' || this.source === undefined || this.source === null) return
973
976
  let that = this
974
- if(n !== 1) that.loading = true
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: this.source,
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
- pdf.getPage(that.pageIndex).then(function (page) {
986
- let canvas = document.getElementById(that.id)
987
- let canvas2 = document.getElementById(`${that.id}2`)
988
- that.ctx = canvas.getContext('2d');
989
- let ctx2 = canvas2.getContext('2d');
990
- let viewport = page.getViewport({scale: that.scales})
991
- canvas.width = viewport.width * that.sratio
992
- canvas.height = viewport.height * that.sratio
993
- canvas.style.width = viewport.width + 'px'
994
- canvas.style.height = viewport.height + 'px'
995
- canvas2.width = viewport.width * that.sratio
996
- canvas2.height = viewport.height * that.sratio
997
- canvas2.style.width = viewport.width + 'px'
998
- canvas2.style.height = viewport.height + 'px'
999
- that.canvasStyle = {
1000
- width: viewport.width + 'px',
1001
- height: viewport.height + 'px',
1002
- marginLeft: -(viewport.width / 2) + 'px',
1003
- widthCanvas: viewport.width * that.sratio,
1004
- heightCanvas: viewport.height * that.sratio
1005
- }
1006
- let renderContext = {
1007
- canvasContext: ctx2,
1008
- viewport: viewport,
1009
- transform: [2, 0, 0, 2, 0, 0] //这里会进行放大,解决模糊问题
1010
- }
1011
- page.render(renderContext)
1012
- that.loading = false
1013
- if (that.oneIndex === 'right') {
1014
- that.flipRights = true
1015
- that.flipLefts = false
1016
- } else {
1017
- that.flipRights = false
1018
- that.flipLefts = true
1019
- }
1020
- // 获取canvas的base64数据
1021
- setTimeout(() => {
1022
- that.flipRights = false
1023
- that.flipLefts = false
1024
- that.oneShow = false
1025
- that.imgArr[that.pageIndex] = canvas2.toDataURL('image/jpeg', 1)
1026
- that.processing()
1027
- }, 1000)
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
- //cursor: none;
1260
+ //cursor: none;
1255
1261
  }
1256
1262
 
1257
1263
  .but-wrap {
package/src/index.js CHANGED
@@ -81,7 +81,7 @@ function install(app) {
81
81
  }
82
82
 
83
83
  export default {
84
- version: '1.32.299',
84
+ version: '1.32.300',
85
85
  install,
86
86
  Calendar,
87
87
  Message,