From 3972db4f9808d325ad853b60b3d77be59a1a4778 Mon Sep 17 00:00:00 2001 From: iven Date: Tue, 26 May 2026 10:38:30 +0800 Subject: [PATCH] =?UTF-8?q?fix(web):=20=E7=A7=AF=E5=88=86=E5=95=86?= =?UTF-8?q?=E5=93=81=E4=BF=9D=E5=AD=98=20=E2=80=94=20=E5=8E=BB=E6=8E=89=20?= =?UTF-8?q?image=5Furl=20=E4=B8=AD=E7=9A=84=E4=B8=B4=E6=97=B6=20token=20?= =?UTF-8?q?=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit MediaPicker 返回含 ?token= 的 URL 用于预览认证,但保存到数据库时应只存纯路径, 避免 JWT token 持久化。同时改进错误提示显示后端返回的具体消息。 --- apps/web/src/pages/health/PointsProductList.tsx | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/apps/web/src/pages/health/PointsProductList.tsx b/apps/web/src/pages/health/PointsProductList.tsx index ce4e09f..941cb67 100644 --- a/apps/web/src/pages/health/PointsProductList.tsx +++ b/apps/web/src/pages/health/PointsProductList.tsx @@ -128,10 +128,12 @@ export default function PointsProductList() { description?: string; sort_order?: number; }; + // 保存时去掉 URL 中的 ?token= 参数(token 是临时的,不应持久化) + const cleanImageUrl = imageUrl ? imageUrl.replace(/\?token=.*$/, '') : undefined; if (editing) { await pointsApi.updateProduct(editing.id, { ...typed, - image_url: imageUrl || undefined, + image_url: cleanImageUrl, version: editing.version, }); } else { @@ -141,7 +143,7 @@ export default function PointsProductList() { points_cost: typed.points_cost, stock: typed.stock, description: typed.description, - image_url: imageUrl || undefined, + image_url: cleanImageUrl, sort_order: typed.sort_order, }; await pointsApi.createProduct(req); @@ -149,8 +151,9 @@ export default function PointsProductList() { message.success(editing ? '更新成功' : '创建成功'); handleCloseDrawer(); refresh(page); - } catch { - message.error(editing ? '更新失败' : '创建失败'); + } catch (err: unknown) { + const apiMsg = (err as { response?: { data?: { message?: string } } })?.response?.data?.message; + message.error(apiMsg || (editing ? '更新失败' : '创建失败')); } };