From 270818c3ad9fd27b756139ff78b140056d7add0f Mon Sep 17 00:00:00 2001 From: iven Date: Sun, 10 May 2026 19:55:13 +0800 Subject: [PATCH] =?UTF-8?q?fix(web):=20=E5=AA=92=E4=BD=93=E5=BA=93?= =?UTF-8?q?=E5=9B=BE=E7=89=87=E6=B7=BB=E5=8A=A0=20JWT=20token=20=E8=AE=A4?= =?UTF-8?q?=E8=AF=81=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit /uploads 路径需要认证,图片 src 须带 ?token= 参数才能正常显示。 MediaLibrary 组件现在从 localStorage 读取 access_token 并附加到图片 URL。 --- apps/web/src/pages/health/MediaLibrary.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/apps/web/src/pages/health/MediaLibrary.tsx b/apps/web/src/pages/health/MediaLibrary.tsx index f2cafb3..c5bf4a6 100644 --- a/apps/web/src/pages/health/MediaLibrary.tsx +++ b/apps/web/src/pages/health/MediaLibrary.tsx @@ -158,7 +158,11 @@ export default function MediaLibrary() { cover={
toggleSelect(item.id)} style={{ height: 140, display: 'flex', alignItems: 'center', justifyContent: 'center', background: 'var(--ant-color-fill-quaternary, #f5f5f5)', overflow: 'hidden', position: 'relative', cursor: 'pointer' }}> {isImage(item.content_type) ? ( - {item.alt_text + { + const base = (item.thumbnail_path || item.storage_path).replace(/^\.\//, '/'); + const token = localStorage.getItem('access_token'); + return token ? `${base}?token=${token}` : base; + })()} alt={item.alt_text || item.filename} style={{ width: '100%', height: '100%', objectFit: 'cover' }} /> ) : ( )}