From 445763e144c0ef98ac3323c854dc30c598a69bf6 Mon Sep 17 00:00:00 2001 From: "DESKTOP-JKIE562\\PC" <1013397054@qq.com> Date: Wed, 3 Jun 2026 17:38:57 +0800 Subject: [PATCH] =?UTF-8?q?perf=EF=BC=9A=E6=BA=90=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E9=A2=84=E8=A7=88=E5=8E=BB=E9=99=A4=E3=80=90=E4=B8=8B=E8=BD=BD?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E3=80=91=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/components/FilePreviewModal.vue | 76 -------------------- 1 file changed, 76 deletions(-) diff --git a/frontend/src/components/FilePreviewModal.vue b/frontend/src/components/FilePreviewModal.vue index 1febc1b9..1452f8ea 100644 --- a/frontend/src/components/FilePreviewModal.vue +++ b/frontend/src/components/FilePreviewModal.vue @@ -48,7 +48,6 @@ const emit = defineEmits<{ const { t } = useI18n(); const isLoading = ref(false); -const isDownloading = ref(false); const error = ref(''); const markdownHtml = ref(''); const excelPreview = ref(null); @@ -150,21 +149,6 @@ const readErrorMessage = async (res: Response) => { return extractErrorMessage(text, fallback); }; -const extractDownloadFilename = (res: Response) => { - const disposition = res.headers.get('content-disposition') || ''; - const utf8Match = disposition.match(/filename\*=UTF-8''([^;]+)/i); - if (utf8Match?.[1]) { - try { - return decodeURIComponent(utf8Match[1]); - } catch { - return utf8Match[1]; - } - } - const asciiMatch = disposition.match(/filename="([^"]+)"/i); - if (asciiMatch?.[1]) return asciiMatch[1]; - return ''; -}; - const applyExcelPreview = (buffer: ArrayBuffer) => { const workbook = XLSX.read(buffer, { type: 'array' }); if (!workbook.SheetNames.length) { @@ -331,42 +315,6 @@ const loadBinaryContent = async () => { officeObjectUrl.value = URL.createObjectURL(blob); }; -const downloadFile = async () => { - if (!props.file?.url || !props.agentId || isDownloading.value) return; - - isDownloading.value = true; - try { - const params = new URLSearchParams({ - agent_id: String(props.agentId), - url: props.file.url, - name: props.file.name || '', - download: '1', - }); - const res = await fetch(`/api/chat/preview-file-raw?${params.toString()}`, { - headers: props.authHeaders || {}, - }); - if (!res.ok) { - throw new Error(await readErrorMessage(res)); - } - - const blob = await res.blob(); - const downloadUrl = URL.createObjectURL(blob); - const link = document.createElement('a'); - link.href = downloadUrl; - link.download = extractDownloadFilename(res) || props.file.name || 'download'; - document.body.appendChild(link); - link.click(); - link.remove(); - window.setTimeout(() => URL.revokeObjectURL(downloadUrl), 1000); - } catch (e: any) { - error.value = t('filePreview.msg.downloadFailed', { - reason: e?.message || t('filePreview.msg.unknownError'), - }); - } finally { - isDownloading.value = false; - } -}; - /** * 在弹窗/文件变化时加载预览内容。 * 流程: @@ -507,16 +455,6 @@ watch(
{{ t('filePreview.title') }}
{{ file.name }}
-
@@ -611,20 +549,6 @@ watch(
This Office file uses a private or non-HTTPS link, so online preview cannot render it.
-
- -