Parcourir la source

fix: pdf预览组件单独打包

Signed-off-by: tangshizhe <48740614+tangshizhe@users.noreply.github.com>
tangshizhe il y a 3 mois
Parent
commit
82a5928a46
2 fichiers modifiés avec 17 ajouts et 16 suppressions
  1. 9 9
      apps/mobile/src/views/common/pdfViewExample.vue
  2. 8 7
      apps/mobile/vite.config.js

+ 9 - 9
apps/mobile/src/views/common/pdfViewExample.vue

@@ -18,10 +18,10 @@
 
 <script>
 import { mapGetters } from 'vuex'
-// import * as pdfjsLib from 'pdfjs-dist/build/pdf'
+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'
+import 'pdfjs-dist/build/pdf.worker.mjs'
 
 export default {
   name: 'PdfViewExample',
@@ -49,14 +49,14 @@ export default {
     }
   },
   mounted() {
-    // const container = document.getElementById('pdf-container')
+    const container = document.getElementById('pdf-container')
 
-    // this.loadPdf(this.pdfUrl, container)
-    // // 监听窗口的 resize 事件,实现自适应效果
-    // window.addEventListener('resize', () => {
-    //   container.innerHTML = ''
-    //   this.loadPdf(this.pdfUrl, container)
-    // })
+    this.loadPdf(this.pdfUrl, container)
+    // 监听窗口的 resize 事件,实现自适应效果
+    window.addEventListener('resize', () => {
+      container.innerHTML = ''
+      this.loadPdf(this.pdfUrl, container)
+    })
   },
   methods: {
     async loadPdf(pdfUrl, container) {

+ 8 - 7
apps/mobile/vite.config.js

@@ -52,7 +52,8 @@ export default defineConfig(({ mode, command }) => {
             'src/ui/index.js': [
               'src/ui/checkbox-group/index.vue',
               'src/ui/history-list/index.vue'
-            ]
+            ],
+            'pdf': ['pdfjs-dist'],
           }
         }
       }
@@ -128,22 +129,22 @@ export default defineConfig(({ mode, command }) => {
       proxy: {
         // 接口解密iframe
         '^/page_decrypt': {
-          target: 'https://jybx2-webtest.jydev.jianyu360.com',
+          target: 'https://jybx-webtest.jydev.jianyu360.com',
           changeOrigin: true
         },
         '/jyapi': {
-          target: 'https://jybx2-webtest.jydev.jianyu360.com',
+          target: 'https://jybx-webtest.jydev.jianyu360.com',
           changeOrigin: true,
           rewrite: path => path.replace(/^\/jyapi/, '')
         },
         '/api': {
-          target: 'https://jybx2-webtest.jydev.jianyu360.com',
+          target: 'https://jybx-webtest.jydev.jianyu360.com',
           changeOrigin: true,
           rewrite: path => path.replace(/^\/api/, '')
         },
-        '/aiChat': 'https://jybx2-webtest.jydev.jianyu360.com',
-        '/commonFunctions': 'https://jybx2-webtest.jydev.jianyu360.com',
-        '/common-module': 'https://jybx2-webtest.jydev.jianyu360.com'
+        '/aiChat': 'https://jybx-webtest.jydev.jianyu360.com',
+        '/commonFunctions': 'https://jybx-webtest.jydev.jianyu360.com',
+        '/common-module': 'https://jybx-webtest.jydev.jianyu360.com'
       }
     }
   }