ソースを参照

fix(文件预览)

sufan 3 ヶ月 前
コミット
101bdd6fe5
共有3 個のファイルを変更した44 個の追加1 個の削除を含む
  1. 2 1
      src/components/Upload/index.vue
  2. 5 0
      src/router/index.js
  3. 37 0
      src/views/perview/pdf.vue

+ 2 - 1
src/components/Upload/index.vue

@@ -452,7 +452,8 @@ export default {
         const newName = `预览图片${fileType || type}`
         window.open(`#/perview?fileId=${idNum}&absolutePath=${absolutePath}&name=${newName}`)
       } else {
-        window.open(`${process.env.VUE_APP_BASE_API}/system/fileStorage/preview?fileId=${idNum}&resource=${fileType ? 0 : 1}#toolbar=0&navpanes=0&scrollbar=0`)
+        window.open(`#/perview/pdf?fileId=${idNum}&resource=${fileType ? 0 : 1}`)
+        // window.open(`${process.env.VUE_APP_BASE_API}/system/fileStorage/preview?fileId=${idNum}&resource=${fileType ? 0 : 1}#toolbar=0&navpanes=0&scrollbar=0`)
       }
     },
     downloadClick(row) {

+ 5 - 0
src/router/index.js

@@ -70,6 +70,11 @@ export const constantRoutes = [
     component: () => import('@/views/perview/index'),
     hidden: true
   },
+  {
+    path: '/perview/pdf',
+    component: () => import('@/views/perview/pdf'),
+    hidden: true
+  },
   {
     path: '/about',
     component: () => import('@/views/perview/about'),

+ 37 - 0
src/views/perview/pdf.vue

@@ -0,0 +1,37 @@
+<template>
+  <div class="pdf-box">
+    <iframe id="pdfIframe" :src="url" frameborder="0" style="width: 100%; height: 100vh; z-index: 0; position: relative;" @contextmenu.prevent />
+    <!-- <div class="pdf-mark" @contextmenu.prevent /> -->
+  </div>
+</template>
+
+<script>
+export default {
+  data() {
+    return {
+      url: ''
+    }
+  },
+  created() {
+    const { fileId, resource } = this.$route.query
+    this.url = `${process.env.VUE_APP_BASE_API}/system/fileStorage/preview?fileId=${fileId}&resource=${resource}#toolbar=0&navpanes=0&scrollbar=0`
+  },
+  mounted() {
+    console.log(window.frames['pdfIframe'].contentWindow, 8888)
+    console.log(window.frames['pdfIframe'].contentDocument.getElementById('viewer'), 11111111)
+    console.log(window.frames['pdfIframe'].document, 2222)
+    window.frames['pdfIframe'].contentDocument.body.oncontextmenu = function() {
+      return false
+    }
+  }
+}
+</script>
+
+<style lang="scss" scoped>
+.pdf-box {
+  width: 100vw;
+  height: 100vh;
+  overflow: hidden;
+  opacity: 0.99;
+}
+</style>