浏览代码

fix: 解决三级页客户端弹窗问题

Signed-off-by: tangshizhe <48740614+tangshizhe@users.noreply.github.com>
tangshizhe 3 月之前
父节点
当前提交
b5ca73a450
共有 4 个文件被更改,包括 32 次插入36 次删除
  1. 2 0
      apps/mobile/index.html
  2. 15 7
      apps/mobile/src/views/common/pdfViewExample.vue
  3. 13 13
      package.json
  4. 2 16
      pnpm-lock.yaml

+ 2 - 0
apps/mobile/index.html

@@ -133,5 +133,7 @@
       src="/common-module/chart-module/js/chart-common.js?v=<%= assets.version %>"
     ></script>
     <% } %>
+    <script src="https://cdn-common.jianyu360.com/cdn/lib/pdfjs-dist/2.1.266/build/pdf.min.js"></script>
+    <script src="https://cdn-common.jianyu360.com/cdn/lib/pdfjs-dist/2.1.266/web/pdf_viewer.js"></script>
   </body>
 </html>

+ 15 - 7
apps/mobile/src/views/common/pdfViewExample.vue

@@ -1,4 +1,4 @@
-<!-- <template>
+<template>
   <div class="pdf-view-example j-contanter">
     <div id="pdf-view-container" class="j-main" />
     <div v-if="!getUserId" class="j-footer">
@@ -16,10 +16,8 @@
 
 <script>
 import { mapGetters } from 'vuex'
-import * as pdfjsLib from 'pdfjs-dist/build/pdf'
 import AdSingle from '@/components/ad/Ad'
 import { getAssetsFile } from '@/utils'
-import 'pdfjs-dist/build/pdf.worker.mjs'
 
 export default {
   name: 'PdfViewExample',
@@ -32,7 +30,16 @@ export default {
       pdf: null,
       totalPages: 0,
       currentPage: 1, // 新增
-      batchSize: 5 // 新增
+      batchSize: 5, // 新增
+      config: {
+        PAGE_TO_VIEW: 0,
+        SCALE: 1.0,
+        CMAP_URL:
+          'https://cdn-common.jianyu360.com/cdn/lib/pdfjs-dist/2.1.266/cmaps/',
+        CMAP_PACKED: true,
+        workerSrc:
+          'https://cdn-common.jianyu360.com/cdn/lib/pdfjs-dist/2.1.266/build/pdf.worker.min.js'
+      }
     }
   },
   computed: {
@@ -65,11 +72,13 @@ export default {
     async loadPdf(pdfUrl, container) {
       console.log('pdfUrl', pdfUrl)
       try {
+        pdfjsLib.GlobalWorkerOptions.workerSrc = this.config.workerSrc
         const loadingTask = pdfjsLib.getDocument({
           url: pdfUrl,
+          cMapUrl: this.config.CMAP_URL,
+          cMapPacked: this.config.CMAP_PACKED,
           disableRange: true,
           disableAutoFetch: false, // 启动自动分块加载
-          workerSrc: 'pdfjs-dist/build/pdf.worker.mjs',
           // 添加缓存头
           httpHeaders: {
             'Cache-Control': 'max-age=3600' // 缓存 1 小时
@@ -79,7 +88,6 @@ export default {
           // 减少初始加载的字节数,提高初始加载速度
           initialDataSize: 1024 * 1024
         })
-        pdfjsLib.GlobalWorkerOptions.workerSrc = 'pdfjs-dist/build/pdf.worker.mjs'
         this.pdf = await loadingTask.promise
         this.totalPages = this.pdf.numPages
         this.currentPage = 1
@@ -131,4 +139,4 @@ export default {
     }
   }
 }
-</script> -->
+</script>

+ 13 - 13
package.json

@@ -1,7 +1,7 @@
 {
   "name": "jy-web",
-  "description": "剑鱼产品整体前端应用,基于 vite、pnpm 构建 monorepo 体系。",
   "private": true,
+  "description": "剑鱼产品整体前端应用,基于 vite、pnpm 构建 monorepo 体系。",
   "workspaces": [
     "packages/*",
     "data/*",
@@ -10,7 +10,14 @@
     "core/*",
     "docs/*"
   ],
+  "author": "",
+  "license": "ISC",
+  "keywords": [],
   "main": "index.js",
+  "engines": {
+    "node": ">=16",
+    "pnpm": ">=8"
+  },
   "scripts": {
     "preinstall": "npx only-allow pnpm",
     "postinstall": "simple-git-hooks",
@@ -30,9 +37,6 @@
     "dev:jy-pc": "pnpm --filter web-pc run dev",
     "build:jy-pc": "pnpm --filter web-pc run build"
   },
-  "keywords": [],
-  "author": "",
-  "license": "ISC",
   "dependencies": {
     "axios": "^1.6.7",
     "qs": "^6.11.2",
@@ -40,24 +44,20 @@
     "vue-router": "^3.6.5"
   },
   "devDependencies": {
+    "@antfu/eslint-config": "^2.25.1",
     "@babel/plugin-proposal-optional-chaining": "^7.21.0",
     "colorette": "^2.0.20",
     "cross-env": "^7.0.3",
+    "eslint": "^8.57.0",
+    "eslint-plugin-format": "^0.1.2",
     "execa": "^7.1.1",
     "inquirer": "^9.1.5",
-    "prettier": "^3.1.0",
     "lint-staged": "^14.0.1",
+    "prettier": "^3.1.0",
     "simple-git-hooks": "^2.11.1",
     "typescript": "^5.0.2",
     "vite": "^4.5.3",
-    "vite-plugin-html-redirect": "^1.0.4",
-    "eslint": "^8.57.0",
-    "@antfu/eslint-config": "^2.25.1",
-    "eslint-plugin-format": "^0.1.2"
-  },
-  "engines": {
-    "node": ">=16",
-    "pnpm": ">=8"
+    "vite-plugin-html-redirect": "^1.0.4"
   },
   "simple-git-hooks": {
     "pre-commit": "pnpm exec lint-staged --concurrent false"

+ 2 - 16
pnpm-lock.yaml

@@ -6850,7 +6850,7 @@ packages:
   /@vueuse/shared@9.13.0(vue@2.7.14):
     resolution: {integrity: sha512-UrnhU+Cnufu4S6JLCPZnkWh0WwZGUp72ktOF2DFptMlOs3TOdVv8xJN53zhHGARmVOsz5KqOls09+J1NR6sBKw==}
     dependencies:
-      vue-demi: 0.14.7(vue@2.7.14)
+      vue-demi: 0.14.6(vue@2.7.14)
     transitivePeerDependencies:
       - '@vue/composition-api'
       - vue
@@ -16937,7 +16937,7 @@ packages:
       '@types/eslint': 8.44.1
       eslint: 8.37.0
       rollup: 2.79.1
-      vite: 4.5.3(less@4.1.3)(sass@1.63.2)(terser@5.19.2)
+      vite: 4.5.3(less@4.1.3)(sass@1.71.1)(terser@5.19.2)
     dev: true
 
   /vite-plugin-externals@0.6.2(vite@4.5.3):
@@ -17516,20 +17516,6 @@ packages:
     dependencies:
       vue: 2.7.14
 
-  /vue-demi@0.14.7(vue@2.7.14):
-    resolution: {integrity: sha512-EOG8KXDQNwkJILkx/gPcoL/7vH+hORoBaKgGe+6W7VFMvCYJfmF2dGbvgDroVnI8LU7/kTu8mbjRZGBU1z9NTA==}
-    engines: {node: '>=12'}
-    hasBin: true
-    requiresBuild: true
-    peerDependencies:
-      '@vue/composition-api': ^1.0.0-rc.1
-      vue: ^3.0.0-0 || ^2.6.0
-    peerDependenciesMeta:
-      '@vue/composition-api':
-        optional: true
-    dependencies:
-      vue: 2.7.14
-
   /vue-demi@0.14.7(vue@3.3.11):
     resolution: {integrity: sha512-EOG8KXDQNwkJILkx/gPcoL/7vH+hORoBaKgGe+6W7VFMvCYJfmF2dGbvgDroVnI8LU7/kTu8mbjRZGBU1z9NTA==}
     engines: {node: '>=12'}