From 62e9986b6d2d20e61a3b65745af33165c9f1534b Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期二, 07 四月 2026 10:01:14 +0800
Subject: [PATCH] 军泰 1.产品维护上传修改
---
src/components/filePreview/index.vue | 56 +++++++++++++-------------------------------------------
1 files changed, 13 insertions(+), 43 deletions(-)
diff --git a/src/components/filePreview/index.vue b/src/components/filePreview/index.vue
index cda5b56..bca7d73 100644
--- a/src/components/filePreview/index.vue
+++ b/src/components/filePreview/index.vue
@@ -6,9 +6,9 @@
<img :src="imgUrl" alt="Image Preview" />
</div>
- <!-- PDF棰勮鎻愮ず -->
- <div v-if="isPdf" style="height: 100vh; display: flex; align-items: center; justify-content: center;">
- <p>姝e湪鍑嗗PDF棰勮...</p>
+ <!-- PDF棰勮 -->
+ <div v-if="isPdf" class="pdf-preview-wrapper">
+ <iframe :src="fileUrl" class="pdf-preview-frame" frameborder="0"></iframe>
</div>
<!-- Word鏂囨。棰勮 -->
@@ -53,7 +53,7 @@
</template>
<script setup>
-import { ref, computed, getCurrentInstance, watch } from 'vue';
+import { ref, computed, getCurrentInstance } from 'vue';
import VueOfficeDocx from '@vue-office/docx';
import '@vue-office/docx/lib/index.css';
import VueOfficeExcel from '@vue-office/excel';
@@ -112,45 +112,6 @@
return isImage.value || isPdf.value || isDoc.value || isXls.value || isZipOrRar.value;
});
-// 鍔ㄦ�佸垱寤篴鏍囩骞惰烦杞瑙圥DF
-const previewPdf = (url) => {
- // 鍒涘缓a鏍囩
- const link = document.createElement('a');
- // 璁剧疆PDF鏂囦欢URL
- link.href = url;
- // 鍦ㄦ柊鏍囩椤垫墦寮�
- link.target = '_blank';
- // 瀹夊叏灞炴�э紝闃叉鏂伴〉闈㈣闂師椤甸潰
- link.rel = 'noopener noreferrer';
- // 鍙�夛細璁剧疆閾炬帴鏂囨湰
- link.textContent = '棰勮PDF';
- // 灏哸鏍囩娣诲姞鍒伴〉闈紙閮ㄥ垎娴忚鍣ㄨ姹傚繀椤诲湪DOM涓級
- document.body.appendChild(link);
- // 瑙﹀彂鐐瑰嚮浜嬩欢
- link.click();
- // 绉婚櫎a鏍囩锛屾竻鐞咲OM
- document.body.removeChild(link);
-};
-
-
-// 鐩戝惉PDF鐘舵�佸彉鍖栵紝鑷姩瑙﹀彂璺宠浆
-watch(
- () => isPdf.value,
- (newVal) => {
-
- // 褰撶‘璁ゆ槸PDF涓旀枃浠禪RL鏈夋晥鏃�
- if (newVal && fileUrl.value) {
- // 鍏抽棴瀵硅瘽妗�
- dialogVisible.value = false;
- // 鍔犱釜灏忓欢杩熺‘淇濈姸鎬佹洿鏂板畬鎴�
- setTimeout(() => {
- previewPdf(fileUrl.value);
- fileUrl.value = '';
- }, 100);
- }
- }
-);
-
// 鏂规硶瀹氫箟
const renderedHandler = () => {
console.log("娓叉煋瀹屾垚");
@@ -194,6 +155,15 @@
margin: 0 auto;
}
+.pdf-preview-wrapper {
+ height: 100vh;
+}
+
+.pdf-preview-frame {
+ width: 100%;
+ height: 100%;
+}
+
.oneLine {
overflow: hidden;
white-space: nowrap;
--
Gitblit v1.9.3