wenhongquan 1 year ago
parent
commit
c5e9aab5a6
3 changed files with 23 additions and 25 deletions
  1. 21 23
      src/components/pdfview/index.vue
  2. 1 1
      src/views/h5/filelist/index.vue
  3. 1 1
      src/views/project/list/index.vue

+ 21 - 23
src/components/pdfview/index.vue

@@ -1,14 +1,17 @@
 <template>
   <div style="width: 100%;height:100%;position:absolute">
-    <!-- <el-watermark :font="font" :content="content" style="width: 100%;height:100%;position:absolute"> -->
-      <iframe v-loading="true" style="width:100%;height:100%;border:none" :src="`${currentPdf}`" />
-    <!-- </el-watermark> -->
+
+    <el-watermark :font="font" :content="watertext" style="width: 100%;height:100%;position:absolute">
+    <iframe v-loading="true" style="width:100%;height:100%;border:none" :src="`${currentPdf}`" v-if="usepdf" />
+      <div style="height: 100%;overflow-y: auto" v-if="!usepdf">
+        <!-- <div v-for="page in pages" :key="page" style="width: 100%;">
+          <VuePDF :pdf="pdf" fit-parent :watermark-text="watermarkText" :watermark-options="watermarkOptions" :page="page">
+            <div v-loading="true"></div>
+          </VuePDF>
+        </div> -->
+      </div>
+    </el-watermark>
   </div>
-  <!-- <div v-for="page in pages" :key="page" style="width: 100%;">
-    <VuePDF :pdf="pdf" fit-parent :watermark-text="watermarkText" :watermark-options="watermarkOptions" :page="page">
-      <div v-loading="true"></div>
-    </VuePDF>
-  </div> -->
 </template>
 <script lang="ts" setup>
 import {ref, onMounted, watchEffect} from 'vue'
@@ -21,9 +24,9 @@ import useUserStore from '@/store/modules/user';
 
 const userStore = useUserStore();
 
-const { watermark } = toRefs<any>(
+const { watermark } = toRefs<any>();
 
-);
+const usepdf=ref(true);
 
 const props = defineProps({
   src: propTypes.string.def(''),
@@ -39,11 +42,15 @@ const watertext = ref();
 
 const currentPdf = ref(props.src)
 watchEffect(() => {
-
-
-
+  if (usepdf.value) {
+    // currentPdf.value = `/preview/onlinePreview?url=${encodeURIComponent(base64.encode(props.src))}&watermarkTxt=${encodeURIComponent(watertext.value)}`;
+    currentPdf.value = `/preview?url=${encodeURIComponent(props.src)}`
+    // http://localhost:8083/preview/?url=https%3A%2F%2Fraw.githubusercontent.com%2Fmozilla%2Fpdf.js%2Fba2edeae%2Fweb%2Fcompressed.tracemonkey-pldi-09.pdf
+  } else {
+    currentPdf.value = props.src;
+  }
   //http://127.0.0.1:8012/onlinePreview?url='+encodeURIComponent(base64Encode(url))
-  currentPdf.value = `/preview/onlinePreview?url=${encodeURIComponent(base64.encode(props.src))}&watermarkTxt=${encodeURIComponent(watertext.value)}`;
+
 
   // currentPdf.value = props.src.replaceAll("https://njdnyjsfilesystem.s3.cn-east-1.qiniucs.com","http://sdrqczwd3.hd-bkt.clouddn.com");
 })
@@ -59,15 +66,6 @@ onMounted(()=>{
 
 
 // const { pdf, pages } = usePDF(currentPdf)
-
-// const watermarkOptions = ref({
-//    columns: 4,
-//   rows: 10,
-//   color: 'rgba(211, 210, 211, 0.8)',
-//   rotation: 45,
-//   fontSize: 18,
-// });
-// const watermarkText = ref('sample')
 </script>
 
 <style lang="scss" scoped></style>

+ 1 - 1
src/views/h5/filelist/index.vue

@@ -22,7 +22,7 @@
     </van-pull-refresh>
 
     <el-dialog v-model="pdfviewshow" :title="`文件预览`" width="90vw">
-      <div style="position: relative;min-height:78vh">
+      <div style="position: relative;min-height:50vh">
         <pdfview :src="currentfile.url"></pdfview>
       </div>
       <!-- <div><el-affix :offset="120" position="bottom"><el-button type="text" icon="DArrowRight"></el-button></el-affix></div>

+ 1 - 1
src/views/project/list/index.vue

@@ -218,7 +218,7 @@
     <el-dialog v-model="pdfviewshow" :title="`文件预览`" width="60vw" >
 
 
-        <div style="position: relative;min-height:78vh">
+        <div style="position: relative;min-height:70vh">
            <el-affix :offset="400" style="width: 100%;">
                <div style="position: absolute;">
                  <el-button type="primary" icon="DArrowLeft" :disabled="ccindex<=0" @click="fileindexlook(ccindex-1)"></el-button>