Browse Source

处理预览空文件

Alfyn 1 month ago
parent
commit
5f2b6eed58
2 changed files with 12 additions and 8 deletions
  1. 1 0
      src/views/document/comp/previewFile.vue
  2. 11 8
      src/views/preview/Preview.vue

+ 1 - 0
src/views/document/comp/previewFile.vue

@@ -34,6 +34,7 @@ export default {
           query: {
             id: record.id,
             extension: record.extension,
+            size: record.size,
             download_url: record.download_url,
           },
         })

+ 11 - 8
src/views/preview/Preview.vue

@@ -16,8 +16,8 @@
       v-if="extension === 'xlsx' || extension === 'xls'"
     />
     <a-spin :spinning="spinning">
-      <div ref="pptx-wrapper" v-if="1"></div>
-      <a-empty v-else/>
+      <div ref="pptx-wrapper" v-if="size !== '0'"></div>
+      <a-empty v-else style="color:white;"/>
     </a-spin>
   </div>
 </template>
@@ -40,8 +40,8 @@ export default {
       id: this.$route.query.id,
       extension: this.$route.query.extension,
       download_url: this.$route.query.download_url,
-
-      spinning:false,
+      size: this.$route.query.size,
+      spinning: false,
       xlslOptions: {
         xls: false, //预览xlsx文件设为false;预览xls文件设为true
         minColLength: 0,
@@ -56,14 +56,14 @@ export default {
   },
   methods: {
     loadPPT() {
-      if (this.extension !== 'pptx') {
+      if (this.extension !== 'pptx' || this.size == 0) {
         return
       }
       this.spinning = true
       this.$nextTick(() => {
         this.pptxPrviewer = init(this.$refs['pptx-wrapper'], {
           width: 1000,
-          height: document.body.clientHeight -10,
+          height: document.body.clientHeight - 10,
         })
         fetch(this.download_url)
           .then((response) => {
@@ -106,7 +106,7 @@ export default {
     border-radius: 10px;
     -webkit-box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
     background: #5353536f;
-    &:hover{
+    &:hover {
       background: #535353;
     }
   }
@@ -116,4 +116,7 @@ export default {
     background: #ededed;
   }
 }
-</style>
+/deep/.docx-wrapper {
+  background: #323639;
+}
+</style>