소스 검색

feat: 添加 showActions 属性以控制「新窗口打开」和「下载」按钮的显示

xieyong 1 주 전
부모
커밋
9cecdc51d6
1개의 변경된 파일과 14개의 추가작업 그리고 3개의 파일을 삭제
  1. 14 3
      src/components/FilePreview/index.vue

+ 14 - 3
src/components/FilePreview/index.vue

@@ -33,13 +33,14 @@
             currentFile.name
           }}</span>
           <el-button
-            v-if="currentFile.url"
+            v-if="showActions && currentFile.url"
             type="text"
             icon="el-icon-view"
             @click="handleOpenWindow"
             >新窗口打开</el-button
           >
           <el-button
+            v-if="showActions"
             type="text"
             icon="el-icon-download"
             :disabled="!currentFile.storePath"
@@ -96,8 +97,13 @@
           <!-- 其它格式:仅支持下载 -->
           <div v-else class="fp-status">
             <i class="el-icon-document" />
-            <p>该格式暂不支持在线预览,请下载后查看</p>
-            <el-button type="primary" size="small" @click="handleDownload"
+            <p v-if="showActions">该格式暂不支持在线预览,请下载后查看</p>
+            <p v-else>该格式暂不支持在线预览</p>
+            <el-button
+              v-if="showActions"
+              type="primary"
+              size="small"
+              @click="handleDownload"
               >下载文件</el-button
             >
           </div>
@@ -139,6 +145,11 @@
       ids: {
         type: [Array, String],
         default: () => []
+      },
+      // 是否显示「新窗口打开」「下载」操作,为false时仅做在线预览
+      showActions: {
+        type: Boolean,
+        default: true
       }
     },
     data() {