zydx-plus 1.19.90 → 1.19.92

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.19.90",
3
+ "version": "1.19.92",
4
4
  "description": "Vue.js",
5
5
  "main": "src/index.js",
6
6
  "files": [
@@ -22,7 +22,6 @@
22
22
  "dependencies": {
23
23
  "vue-draggable-next": "^2.1.1",
24
24
  "pdfjs-dist": "^2.0.943",
25
- "flipbook-vue": "^1.0.0-beta.4",
26
25
  "@wangeditor/editor": "^5.1.23",
27
26
  "@wangeditor/plugin-upload-attachment": "^1.1.0",
28
27
  "snabbdom": "^3.5.1",
@@ -59,8 +59,8 @@ export default {
59
59
  }
60
60
  },
61
61
  mounted() {
62
- let clientWidth = window.outerWidth;
63
- let clientHeight = window.outerHeight;
62
+ let clientWidth = document.documentElement.clientWidth;
63
+ let clientHeight = document.documentElement.clientHeight;
64
64
  this.x = clientWidth / 2 - this.footDownOffset / 2;
65
65
  this.y = clientHeight / 2 - this.footRightOffset / 2;
66
66
  },
@@ -1,45 +1,46 @@
1
1
  <template>
2
2
  <div id="docView">
3
- <div v-show="show" class="load-pop">
4
- <div class="load">
5
- <span>文件较大耐心等待</span>
6
- <div class="loading">
7
- <div class="loading-cont" :style="{'width': loadWidth +'%'}"></div>
3
+ <div style="height: 100%;">
4
+ <div class="book">
5
+ <div class="pages">
6
+ <div class="wrap" id="canvas-wrap"></div>
7
+ <div class="page-but-left" :style="{cursor: pageIndex === 1?'default':'pointer'}" @click="flipLeft(pageIndex-=1,false)"></div>
8
+ <div class="page-but-right" :style="{cursor: pageIndex === pdfPages?'default':'pointer'}" @click="flipRight(pageIndex+=1,false)"></div>
9
+ <!-- <div class="paper z-in" :class="{'data-right': pages}">-->
10
+ <!-- <div class="page page-2" id="canvas-wrap1"></div>-->
11
+ <!-- <div class="page page-2-back" id="canvas-wrap2"></div>-->
12
+ <!-- </div>-->
13
+ <!-- <div class="paper z-in-ac">-->
14
+ <!-- <div class="page page-2" id="canvas-wrap3"></div>-->
15
+ <!-- <div class="page page-2-back" id="canvas-wrap4"></div>-->
16
+ <!-- </div>-->
8
17
  </div>
9
18
  </div>
10
- </div>
11
- <div v-show="!show" style="height: 100%;">
12
- <div class="pdf-container">
13
- <canvas :id="'pdf-canvas'+ index" v-for="(item,index) in pdfPages" class="pdf-canvas"></canvas>
14
- </div>
15
- <div class="book">
16
- <flipbook class="flipbook" :startPage="pageIndex" :pages="imgArr" @flip-left-end="flipLeft($event,false)" @flip-right-end="flipRight($event,false)" v-slot="flipbook" :singlePage="singlePage" :ambient="0" :gloss="1" :dragToFlip="false" :pagesHiRes="0">
17
- <div class="but" v-if="butShow">
18
- <button class="but-brown" :class="{'but-act': pageIndex === 1}" @click="flipbook.flipLeft">上一页</button>
19
- <button class="but-brown" :class="{'but-act': pageIndex === pdfPages}" @click="flipbook.flipRight">下一页</button>
20
- </div>
21
- </flipbook>
19
+ <div class="but-wrap" v-if="butShow">
20
+ <button class="but-brown" :disabled="pageIndex === 1" :class="{'but-act': pageIndex === 1}" @click="flipLeft(pageIndex-=1,false)">上一页</button>
21
+ <button class="but-brown" :disabled="pageIndex === pdfPages" :class="{'but-act': pageIndex === pdfPages}" @click="flipRight(pageIndex+=1,false)">下一页</button>
22
22
  </div>
23
23
  </div>
24
24
  </div>
25
25
  </template>
26
26
 
27
27
  <script>
28
- import flipbook from 'flipbook-vue'
29
28
  import * as PdfJs from 'pdfjs-dist/legacy/build/pdf.js' // 注意导入的写法
30
29
  PdfJs.GlobalWorkerOptions.workerSrc = require('pdfjs-dist/build/pdf.worker.entry')
31
30
  export default {
32
31
  name: "zydx-flip",
33
- components: {flipbook},
34
32
  data() {
35
33
  return {
36
34
  pdfPages: 0,
37
- imgArr: [],
35
+ imgArr: {},
38
36
  hei: 0,
39
37
  pageIndex: this.page,
40
38
  show: false,
41
39
  load: 0,
42
- loadWidth: 0
40
+ loadWidth: 0,
41
+ pages: false,
42
+ pagesData: [],
43
+ opacity: 1
43
44
  }
44
45
  },
45
46
  props: {
@@ -60,79 +61,67 @@ export default {
60
61
  default: 1
61
62
  }
62
63
  },
64
+ watch: {
65
+ page: {
66
+ handler: function (val, oldVal) {
67
+ this.pageIndex = val
68
+ },
69
+ immediate: true
70
+ }
71
+ },
63
72
  emits: ['flip'],
64
73
  mounted() {
65
- this.$nextTick(() => {
66
- this.readPdf()
67
- })
74
+ this.readPdf()
68
75
  },
69
76
  methods: {
70
77
  flipLeft(e,v) {
71
- this.pageIndex = e
78
+ if(e <= 1) {
79
+ this.pageIndex = 1
80
+ }else {
81
+ this.pageIndex = e
82
+ }
83
+ this.readPdf()
72
84
  if(!v) {
73
85
  this.$emit('flip', {
74
- page: e,
86
+ page: this.pageIndex,
75
87
  total: this.pdfPages
76
88
  })
77
89
  }
78
90
  },
79
91
  flipRight(e,v) {
80
- this.pageIndex = e
92
+ if(e >= this.pdfPages) {
93
+ this.pageIndex = this.pdfPages
94
+ }else {
95
+ this.pageIndex = e
96
+ }
97
+ this.readPdf()
81
98
  if(!v) {
82
99
  this.$emit('flip', {
83
- page: e,
100
+ page: this.pageIndex,
84
101
  total: this.pdfPages
85
102
  })
86
103
  }
87
104
  },
88
105
  readPdf() {
89
106
  let that = this
90
- if(that.pdfPages > 30) that.show = true
91
107
  const loadingTask = PdfJs.getDocument(this.source)
92
108
  loadingTask.promise.then((pdf) => {
93
109
  that.pdfPages = pdf.numPages // 获取pdf文件的总页数
94
- for (let i = 0; i < that.pdfPages; i++) {
95
- pdf.getPage(i + 1).then(function (page) {
96
- const canvas = document.getElementById('pdf-canvas' + i)
97
- const ctx = canvas.getContext('2d')
98
- const dpr = window.devicePixelRatio || 1
99
- const bsr = ctx.webkitBackingStorePixelRatio || ctx.mozBackingStorePixelRatio || ctx.msBackingStorePixelRatio || ctx.oBackingStorePixelRatio || ctx.backingStorePixelRatio || 1
100
- const ratio = dpr / bsr
101
- const viewport = page.getViewport({scale: 1})
102
- canvas.width = viewport.width * ratio
103
- canvas.height = viewport.height * ratio
104
- canvas.style.width = viewport.width + 'px'
105
- canvas.style.height = viewport.height + 'px'
106
- ctx.setTransform(ratio, 0, 0, ratio, 0, 0)
107
- const renderContext = {
108
- canvasContext: ctx,
109
- viewport: viewport
110
- }
111
- page.render(renderContext)
112
- if(that.pdfPages > 30) {
113
- that.load = i + 1
114
- that.loadWidth = Math.floor(that.load / that.pdfPages * 100)
115
- }
116
- });
117
- }
118
- setTimeout(function () {
119
- for (let i = 0; i < that.pdfPages; i++) {
120
- const canvas = document.getElementById('pdf-canvas' + i)
121
- const dataURL = canvas.toDataURL("image/jpeg", 1); //获取Base64编码
122
- that.imgArr.push(dataURL)
123
- that.load = i + 1
124
- if(that.pdfPages > 30) {
125
- if(that.load >= that.pdfPages) {
126
- setTimeout(() => {
127
- that.show = false
128
- that.load = 0
129
- },100)
130
- }else {
131
- that.loadWidth = Math.floor(that.load / that.pdfPages * 100)
132
- }
133
- }
134
- }
135
- }, 500)
110
+ pdf.getPage(that.pageIndex).then(function (page) {
111
+ let viewport = page.getViewport({scale: 1})
112
+ document.getElementById('canvas-wrap').innerHTML = ''
113
+ let container = document.createElement('div')
114
+ container.style.width = viewport.width + 'px'
115
+ container.style.height = viewport.height + 'px'
116
+ container.style.margin = '0 auto'
117
+ document.getElementById('canvas-wrap').appendChild(container)
118
+ return page.getOperatorList().then(function(opList) {
119
+ let svgGfx = new PdfJs.SVGGraphics(page.commonObjs, page.objs)
120
+ return svgGfx.getSVG(opList, viewport).then(function(svg) {
121
+ container.appendChild(svg)
122
+ })
123
+ })
124
+ })
136
125
  })
137
126
  }
138
127
  }
@@ -140,39 +129,90 @@ export default {
140
129
  </script>
141
130
 
142
131
  <style scoped>
143
- .load-pop{
144
- width: 100%;
145
- height: 100%;
146
- display: flex;
147
- align-items: center;
132
+ .wrap{
133
+ width: 100%;
134
+ height: 100%;
148
135
  }
149
- .load{
150
- display: inline-block;
151
- margin: 0 auto;
136
+ .but-wrap{
137
+ text-align: center;
152
138
  }
153
- .load>span{
154
- display: inline-block;
139
+ .z-in{
140
+ z-index: 2;
141
+ }
142
+ .z-in-ac{
143
+ z-index: 1;
144
+ }
145
+ .pages{
146
+ width: 100%;
147
+ height: 100%;
148
+ position: relative;
149
+ }
150
+ .paper{
151
+ position: absolute;
152
+ right: 0;
153
+ transform-style: preserve-3d;
155
154
  width: 100%;
155
+ }
156
+ .page{
157
+ position: absolute;
156
158
  text-align: center;
157
- padding-bottom: 10px;
158
- font-size: 14px;
159
159
  }
160
- .loading{
161
- width: 200px;
162
- height: 10px;
163
- border-radius: 20px;
164
- position: relative;
165
- overflow: hidden;
166
- background-color: #ccc;
160
+ .page img{
161
+ width: 100%;
162
+ height: 100%;
163
+ }
164
+ .data-right {
165
+ opacity: 1;
166
+ transform-origin: left center;
167
+ animation: flip-to-left 1.5s ease-in-out forwards;
167
168
  }
168
- .loading-cont{
169
+ .data-left{
170
+ right: auto;
171
+ left: 0;
172
+ }
173
+ @keyframes flip-to-left {
174
+ 0% {
175
+ transform: perspective(3000px) rotateY(0);
176
+ }
177
+ 95% {
178
+ transform: perspective(3000px) rotateY(-180deg);
179
+ }
180
+ 100% {
181
+ transform: perspective(3000px) rotateY(-180deg);
182
+ }
183
+ }
184
+ .page-1-back, .page-2-back {
185
+ transform: scale(-1, 1);
186
+ }
187
+ .page-1, .page-2 {
188
+ transform: translateZ(1px);
189
+ }
190
+
191
+
192
+
193
+
194
+ .page-but-left{
169
195
  position: absolute;
170
196
  top: 0;
197
+ bottom: 0;
171
198
  left: 0;
172
199
  z-index: 1;
173
- background-color: #5daf34;
174
- height: 100%;
175
- border-radius: 20px;
200
+ width: 10%;
201
+ }
202
+ .page-but-right{
203
+ position: absolute;
204
+ top: 0;
205
+ bottom: 0;
206
+ right: 0;
207
+ z-index: 1;
208
+ width: 10%;
209
+ }
210
+ .load>span{
211
+ display: inline-block;
212
+ width: 100%;
213
+ text-align: center;
214
+ padding-bottom: 10px;
215
+ font-size: 14px;
176
216
  }
177
217
  #docView{
178
218
  height: 100%;
@@ -189,33 +229,10 @@ export default {
189
229
  cursor: pointer;
190
230
  margin-left: 10px;
191
231
  }
192
- .but{
193
- position: absolute;
194
- bottom: 0;
195
- left: 0;
196
- right: 0;
197
- z-index: 1;
198
- text-align: center;
199
- }
200
232
  .book{
201
233
  width: 100%;
202
234
  height: 100%;
203
235
  }
204
- .flipbook {
205
- width: 100%;
206
- height: 100%;
207
- position: relative;
208
- padding-bottom: 24px;
209
- }
210
- .pdf-container{
211
- position: relative;
212
- }
213
- .pdf-canvas{
214
- position: absolute;
215
- top: -100000px;
216
- left: 0;
217
- z-index: -100;
218
- }
219
236
  .but-act{
220
237
  background-color: #bbbbbb;
221
238
  color: #fff;
@@ -41,6 +41,15 @@ export default {
41
41
  default: '',
42
42
  }
43
43
  },
44
+ watch: {
45
+ url: {
46
+ handler: function (val, oldVal) {
47
+ this.fileType = val.split('.').pop()
48
+ if(this.fileType === 'pdf') this.init()
49
+ },
50
+ immediate: true
51
+ }
52
+ },
44
53
  mounted() {
45
54
  this.fileType = this.url.split('.').pop()
46
55
  if(this.fileType === 'pdf') this.init()
package/src/index.js CHANGED
@@ -57,7 +57,7 @@ function install(app) {
57
57
  }
58
58
 
59
59
  export default {
60
- version: '1.19.90',
60
+ version: '1.19.92',
61
61
  install,
62
62
  Calendar,
63
63
  Message,