zydx-plus 1.15.60 → 1.15.61

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.15.60",
3
+ "version": "1.15.61",
4
4
  "description": "Vue.js",
5
5
  "main": "src/index.js",
6
6
  "files": [
@@ -4,8 +4,8 @@
4
4
  <canvas :id="'pdf-canvas'+ index" v-for="(item,index) in pdfPages" class="pdf-canvas"></canvas>
5
5
  </div>
6
6
  <div class="book">
7
- <flipbook class="flipbook" :pages="imgArr" @flip-left-end="flipLeft" @flip-right-end="flipRight" v-slot="flipbook" :singlePage="singlePage" :ambient="0" :gloss="1" :dragToFlip="false" :pagesHiRes="0">
8
- <div class="but">
7
+ <flipbook class="flipbook" :startPage="pageIndex" :pages="imgArr" @flip-left-end="flipLeft" @flip-right-end="flipRight" v-slot="flipbook" :singlePage="singlePage" :ambient="0" :gloss="1" :dragToFlip="false" :pagesHiRes="0">
8
+ <div class="but" v-if="butShow">
9
9
  <button class="but-brown" :class="{'but-act': pageIndex === 1}" @click="flipbook.flipLeft">上一页</button>
10
10
  <button class="but-brown" :class="{'but-act': pageIndex === pdfPages}" @click="flipbook.flipRight">下一页</button>
11
11
  </div>
@@ -26,7 +26,7 @@ export default {
26
26
  pdfPages: 0,
27
27
  imgArr: [],
28
28
  hei: 0,
29
- pageIndex: 1
29
+ pageIndex: this.page
30
30
  }
31
31
  },
32
32
  props: {
@@ -38,61 +38,70 @@ export default {
38
38
  type: Boolean,
39
39
  default: false
40
40
  },
41
+ butShow: {
42
+ type: Boolean,
43
+ default: true
44
+ },
45
+ page: {
46
+ type: Number,
47
+ default: 1
48
+ }
41
49
  },
50
+ emits: ['flip'],
42
51
  mounted() {
43
52
  this.$nextTick(() => {
44
53
  this.readPdf()
45
54
  })
46
55
  },
47
56
  methods: {
48
- flipLeft(e) {
49
- this.pageIndex = e
50
- this.$emit('flip',{
51
- page: e,
52
- total: this.pdfPages
53
- })
54
- },
55
- flipRight(e) {
56
- this.pageIndex = e
57
- this.$emit('flip',{
58
- page: e,
59
- total: this.pdfPages
60
- })
61
- },
62
- readPdf() {
63
- let that = this
64
- const loadingTask = PdfJs.getDocument(this.source)
65
- loadingTask.promise.then((pdf) => {
66
- that.pdfPages = pdf.numPages // 获取pdf文件的总页数
67
- for(let i=0; i<that.pdfPages; i++) {
68
- pdf.getPage(i+1).then(function(page) {
69
- const canvas = document.getElementById('pdf-canvas' + i)
70
- const ctx = canvas.getContext('2d')
71
- const dpr = window.devicePixelRatio || 1
72
- const bsr = ctx.webkitBackingStorePixelRatio || ctx.mozBackingStorePixelRatio || ctx.msBackingStorePixelRatio || ctx.oBackingStorePixelRatio || ctx.backingStorePixelRatio || 1
73
- const ratio = dpr / bsr
74
- const viewport = page.getViewport({ scale: 1 })
75
- canvas.width = viewport.width * ratio
76
- canvas.height = viewport.height * ratio
77
- canvas.style.width = viewport.width + 'px'
78
- canvas.style.height = viewport.height + 'px'
79
- ctx.setTransform(ratio, 0, 0, ratio, 0, 0)
80
- const renderContext = {
81
- canvasContext: ctx,
82
- viewport: viewport
83
- }
84
- page.render(renderContext)
85
- });
86
- }
87
- setTimeout(() => {
88
- for(let i=0; i<that.pdfPages; i++) {
89
- const canvas = document.getElementById('pdf-canvas' + i)
90
- const dataURL = canvas.toDataURL("image/jpeg",1); //获取Base64编码
91
- that.imgArr.push(dataURL)
92
- }
93
- },500)
94
- })
95
- }
57
+ flipLeft(e) {
58
+ this.pageIndex = e
59
+ this.$emit('flip', {
60
+ page: e,
61
+ total: this.pdfPages
62
+ })
63
+ },
64
+ flipRight(e) {
65
+ this.pageIndex = e
66
+ this.$emit('flip', {
67
+ page: e,
68
+ total: this.pdfPages
69
+ })
70
+ },
71
+ readPdf() {
72
+ let that = this
73
+ const loadingTask = PdfJs.getDocument(this.source)
74
+ loadingTask.promise.then((pdf) => {
75
+ that.pdfPages = pdf.numPages // 获取pdf文件的总页数
76
+ for (let i = 0; i < that.pdfPages; i++) {
77
+ pdf.getPage(i + 1).then(function (page) {
78
+ const canvas = document.getElementById('pdf-canvas' + i)
79
+ const ctx = canvas.getContext('2d')
80
+ const dpr = window.devicePixelRatio || 1
81
+ const bsr = ctx.webkitBackingStorePixelRatio || ctx.mozBackingStorePixelRatio || ctx.msBackingStorePixelRatio || ctx.oBackingStorePixelRatio || ctx.backingStorePixelRatio || 1
82
+ const ratio = dpr / bsr
83
+ const viewport = page.getViewport({scale: 1})
84
+ canvas.width = viewport.width * ratio
85
+ canvas.height = viewport.height * ratio
86
+ canvas.style.width = viewport.width + 'px'
87
+ canvas.style.height = viewport.height + 'px'
88
+ ctx.setTransform(ratio, 0, 0, ratio, 0, 0)
89
+ const renderContext = {
90
+ canvasContext: ctx,
91
+ viewport: viewport
92
+ }
93
+ page.render(renderContext)
94
+ });
95
+ }
96
+ setTimeout(() => {
97
+ for (let i = 0; i < that.pdfPages; i++) {
98
+ const canvas = document.getElementById('pdf-canvas' + i)
99
+ const dataURL = canvas.toDataURL("image/jpeg", 1); //获取Base64编码
100
+ that.imgArr.push(dataURL)
101
+ }
102
+ }, 500)
103
+ })
104
+ }
96
105
  }
97
106
  }
98
107
  </script>
package/src/index.js CHANGED
@@ -49,7 +49,7 @@ function install(app) {
49
49
  }
50
50
 
51
51
  export default {
52
- version: '1.15.60',
52
+ version: '1.15.61',
53
53
  install,
54
54
  Calendar,
55
55
  Message,