From a7cb2865a936b9e233b7e9c299fe908645aa4807 Mon Sep 17 00:00:00 2001 From: wangziqi Date: Tue, 7 Jul 2026 10:03:19 +0800 Subject: [PATCH] fix: update StudentProfileContent report buttons to use /report-html, remove dead /report references --- .../StudentProfileContent/index.tsx | 45 +++++-------------- 1 file changed, 10 insertions(+), 35 deletions(-) diff --git a/apps/admin/src/components/StudentProfileContent/index.tsx b/apps/admin/src/components/StudentProfileContent/index.tsx index 8b4db9c..2a6ccd9 100644 --- a/apps/admin/src/components/StudentProfileContent/index.tsx +++ b/apps/admin/src/components/StudentProfileContent/index.tsx @@ -29,8 +29,6 @@ import { EyeOutlined, CloseOutlined, FileTextOutlined, - FilePdfOutlined, - CameraOutlined, ReloadOutlined, } from '@ant-design/icons'; import dayjs from 'dayjs'; @@ -741,33 +739,16 @@ const StudentProfileContent: React.FC = ({ void fetchData(); }, [fetchData]); - const handleDownloadReport = useCallback(() => { - const token = localStorage.getItem('token'); - window.open(`/api/archive/${studentId}/report?token=${token}`, '_blank'); - }, [studentId]); - - const handlePreviewReport = useCallback(() => { - const token = localStorage.getItem('token'); - window.open(`/api/archive/${studentId}/report?token=${token}`, '_blank'); - }, [studentId]); - - const handleDownloadPdf = useCallback(async () => { - const token = localStorage.getItem('token'); + const handlePreviewReport = useCallback(async () => { try { - const res = await fetch(`/api/archive/${studentId}/report`, { - headers: { Authorization: `Bearer ${token}` }, - }); - if (!res.ok) throw new Error('下载失败'); - const blob = await res.blob(); - const url = URL.createObjectURL(blob); - const a = document.createElement('a'); - a.href = url; - a.download = `学员档案_${studentId}.pdf`; - a.click(); - URL.revokeObjectURL(url); - } catch (e: unknown) { - const err = e as { message?: string }; - message.error(err?.message || 'PDF下载失败'); + const { html } = await api.get<{ html: string }>(`/archive/${studentId}/report-html`); + const w = window.open('', '_blank'); + if (w) { + w.document.write(html); + w.document.close(); + } + } catch { + message.error('加载报告失败'); } }, [studentId]); @@ -787,13 +768,7 @@ const StudentProfileContent: React.FC = ({ - -