@toolspack/ttd-pdfjs 0.0.5 → 0.0.6

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": "@toolspack/ttd-pdfjs",
3
- "version": "0.0.5",
3
+ "version": "0.0.6",
4
4
  "private": false,
5
5
  "main": "lib/ttd-pdfjs.umd.min.js",
6
6
  "scripts": {
@@ -13,7 +13,7 @@
13
13
  "babel-cli": "^6.26.0",
14
14
  "babel-laoder": "0.0.1-security",
15
15
  "babel-polyfill": "^6.26.0",
16
- "core-js": "^3.6.5",
16
+ "core-js": "^3.34.0",
17
17
  "element-ui": "^2.15.14",
18
18
  "less": "^3.8.1",
19
19
  "less-loader": "^4.1.0",
package/src/App.vue CHANGED
@@ -55,7 +55,7 @@ export default {
55
55
  },
56
56
  handelProgress(event, file, fileList) {
57
57
  this.progressCurrent = event.percent
58
- console.log('progress', event, file, fileList)
58
+ // console.log('progress', event, file, fileList)
59
59
  },
60
60
  tips(words = []) {
61
61
  if (Array.isArray(words) && words.length > 0) {
@@ -77,6 +77,7 @@ export default {
77
77
  // url: file.url,
78
78
  // fileMD5: file.fileMD5
79
79
  // }
80
+ console.log('upload: ', list[0])
80
81
  this.url = list[0].url
81
82
  } else {
82
83
  console.log(msg || '上传失败!')
@@ -26,22 +26,45 @@
26
26
  </template>
27
27
  <script>
28
28
 
29
+ import { Message } from 'element-ui';
29
30
  import SwitchPage from './SwitchPage.vue'
30
31
 
32
+ function getChromeVersion() {
33
+ const arr = navigator.userAgent.split(' ');
34
+ let chromeVersion = '';
35
+ for (let i = 0; i < arr.length; i++) {
36
+ if (/chrome/i.test(arr[i])) chromeVersion = arr[i]
37
+ }
38
+ if (chromeVersion) {
39
+ return Number(chromeVersion.split('/')[1].split('.')[0]);
40
+ }
41
+ return false;
42
+ }
43
+ let version = ''
44
+ if (getChromeVersion()) {
45
+ version = getChromeVersion();
46
+ if (version < 98) {
47
+ Message({
48
+ message: `您使用的谷歌浏览器版本过低【version:${version}】,为了更好地体验请将浏览器升级到最新版本!`,
49
+ type: 'error',
50
+ duration: 3000,
51
+ })
52
+ }
53
+ }
54
+
55
+ // const PDFJS = require('pdfjs-dist/legacy/build/pdf.js')
31
56
  const PDFJS = require('pdfjs-dist')
32
57
 
33
58
  const defautScale = 1.0
34
59
 
35
- PDFJS.GlobalWorkerOptions.workerSrc = require('pdfjs-dist/legacy/build/pdf.worker.min.js')
60
+ // PDFJS.GlobalWorkerOptions.workerSrc = require('pdfjs-dist/legacy/build/pdf.worker.min.js')
61
+ PDFJS.GlobalWorkerOptions.workerSrc = require('pdfjs-dist/build/pdf.worker.min.js')
36
62
  // https://unpkg.com/pdfjs-dist@2.16.105/cmaps/
63
+ // const cMapUrl = 'https://cdn.jsdelivr.net/npm/pdfjs-dist@3.11.174/cmaps/'
37
64
  // 使用代理的cmaps,会导致加载很慢,改用本地
38
65
 
39
66
  const cMapUrl = 'https://wsp.totodi.com/staticfiles_web/web/pdfjs/cmaps/'
40
67
 
41
- // const cMapUrl = 'https://cdn.jsdelivr.net/npm/pdfjs-dist@3.11.174/cmaps/'
42
-
43
- // const cMapUrl = 'https://petx.totodi.com/jz/pdfjs/cmaps'
44
-
45
68
  export default {
46
69
  components: { SwitchPage },
47
70
  props: {
@@ -133,7 +156,7 @@ export default {
133
156
  canvasContext: canvas.getContext('2d'),
134
157
  viewport,
135
158
  }
136
- const renderTask = page.render(renderContext)
159
+ const renderTask = await page.render(renderContext)
137
160
 
138
161
  // Wait for rendering to finish
139
162
  await renderTask.promise
@@ -176,7 +199,6 @@ export default {
176
199
  },
177
200
  closepdf() {
178
201
  // 关闭PDF
179
- console.log('closepdf - begin')
180
202
  if (this.pdfDoc) {
181
203
  if (this.viewport) {
182
204
  const { canvas } = this.$refs
@@ -212,7 +234,6 @@ export default {
212
234
  console.log('----PdfView---', url)
213
235
  let pdfDoc_
214
236
  try {
215
- console.log('888--')
216
237
  // const pdfData = await fetch(
217
238
  // new URL(url, window.location).href,
218
239
  // );
@@ -224,7 +245,6 @@ export default {
224
245
  cMapPacked: true,
225
246
  }).promise
226
247
  } catch (error) {
227
- console.log('999999--')
228
248
  console.error(error)
229
249
 
230
250
  const pdfData = await fetch(
@@ -239,13 +259,11 @@ export default {
239
259
  // 初始化pdf
240
260
  if (this.pdfDoc) {
241
261
  console.log('pdfDocument is ready destroy,,')
242
- this.closepdf();
262
+ await this.closepdf();
243
263
  this.pdfDoc = null
244
- console.log('pdfDocument is destroy')
245
264
  }
246
265
  this.pdfDoc = pdfDoc_
247
266
  this.page_count = pdfDoc_.numPages
248
- console.log('this.page_count', this.page_count)
249
267
  this.$emit('numPages', pdfDoc_.numPages)
250
268
  this.renderPage(this.pageNum)
251
269
  this.emitPage(this.pageNum)
@@ -286,9 +304,7 @@ export default {
286
304
  this.initPage = true
287
305
  this.loadUrl(val)
288
306
  if (this.pdfDoc) {
289
- console.log('wtach 3333')
290
307
  this.closepdf();
291
- console.log('wtach 444')
292
308
  }
293
309
  }
294
310
  if (this.showPages) {