From 322bbdf47d59a6ba458674511d16e47adf57efe5 Mon Sep 17 00:00:00 2001 From: kenyanghui Date: Sun, 15 Nov 2026 12:07:46 +0800 Subject: [PATCH] =?UTF-8?q?fix(server):=20PUT=20/activities/:id=20?= =?UTF-8?q?=E6=94=B9=E9=83=A8=E5=88=86=E6=9B=B4=E6=96=B0=E2=80=94=E2=80=94?= =?UTF-8?q?=E6=9C=AA=E4=BC=A0=E5=AD=97=E6=AE=B5=E4=BF=9D=E7=95=99=E5=8E=9F?= =?UTF-8?q?=E5=80=BC=EF=BC=8C=E9=98=B2=E6=AD=A2=E7=BC=96=E8=BE=91=E9=A1=B5?= =?UTF-8?q?=E6=BC=8F=E4=BC=A0=E6=B8=85=E7=A9=BA=E6=8F=8F=E8=BF=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- yaoyue-sever/server/server.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/yaoyue-sever/server/server.js b/yaoyue-sever/server/server.js index a3960d8..a1c53a5 100644 --- a/yaoyue-sever/server/server.js +++ b/yaoyue-sever/server/server.js @@ -1560,9 +1560,22 @@ app.put('/activities/:id', requireActivityAdmin, (req, res) => { } const now = new Date().toISOString(); + // 部分更新:未传字段保留原值,避免编辑页漏传把描述等字段清空 + const merged = { + title: title ?? activity.title, + cover_url: cover_url ?? activity.cover_url, + description: description ?? activity.description, + location: location ?? activity.location, + start_time: start_time ?? activity.start_time, + duration: duration ?? activity.duration, + max_participants: max_participants ?? activity.max_participants, + fee: fee ?? activity.fee, + organizer: organizer ?? activity.organizer, + checkin_enabled: checkin_enabled === undefined ? activity.checkin_enabled : (checkin_enabled ? 1 : 0), + }; db.prepare(` UPDATE activities SET title = ?, cover_url = ?, description = ?, location = ?, start_time = ?, duration = ?, max_participants = ?, fee = ?, organizer = ?, checkin_enabled = ?, updated_at = ? WHERE id = ? - `).run(title, cover_url || '', description || '', location, start_time, duration || 1, max_participants || 50, fee || 0, organizer || '', checkin_enabled ? 1 : 0, now, id); + `).run(merged.title, merged.cover_url, merged.description, merged.location, merged.start_time, merged.duration, merged.max_participants, merged.fee, merged.organizer, merged.checkin_enabled, now, id); // 更新标签 if (tags && Array.isArray(tags)) {