From d2f6dac989a5f522c14b0243140d8f1639fed975 Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期四, 06 八月 2026 17:24:39 +0800
Subject: [PATCH] 银川 1.添加全局预览附件功能

---
 src/components/upload/file-upload.vue |   14 ++++++--------
 1 files changed, 6 insertions(+), 8 deletions(-)

diff --git a/src/components/upload/file-upload.vue b/src/components/upload/file-upload.vue
index 15eb640..b095bdd 100644
--- a/src/components/upload/file-upload.vue
+++ b/src/components/upload/file-upload.vue
@@ -143,7 +143,6 @@
 }
 
 const { openPreview, previewState } = useFilePreview();
-const previewLoading = ref(false);
 
 /** 澶勭悊鏂囦欢棰勮 */
 async function handlePreview(file: UploadFile) {
@@ -157,17 +156,16 @@
     window.open(url, '_blank');
     return;
   }
-  previewLoading.value = true;
   try {
-    const blob = await requestClient.get(url, { responseType: 'blob' }) as unknown as Blob;
-    const blobUrl = URL.createObjectURL(blob);
+    // 灏嗙粷瀵� URL 杞负鐩稿璺緞锛岃蛋 Vite 浠g悊閬垮厤璺ㄥ煙
+    const path = typeof url === 'string' ? url.replace(/^https?:\/\/[^/]+/, '') : url;
+    const blob = await requestClient.download(path);
+    const blobUrl = URL.createObjectURL(blob as Blob);
     openPreview(blobUrl, name);
+    emit('preview', file);
   } catch {
-    message.error('鏂囦欢鍔犺浇澶辫触锛岃灏濊瘯涓嬭浇鍚庢煡鐪�');
-  } finally {
-    previewLoading.value = false;
+    message.error('鏂囦欢鍔犺浇澶辫触');
   }
-  emit('preview', file);
 }
 
 /** 澶勭悊鏂囦欢鏁伴噺瓒呴檺 */

--
Gitblit v1.9.3