From 16a2c7a043c5a5cc9e8067da9de6f7941b295812 Mon Sep 17 00:00:00 2001 From: ddshi <8811906+ddshi@user.noreply.gitee.com> Date: Mon, 2 Mar 2026 17:51:11 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=88=9B=E5=BB=BA=E5=BE=AA=E7=8E=AF?= =?UTF-8?q?=E4=BA=8B=E4=BB=B6=E6=97=B6=E8=87=AA=E5=8A=A8=E8=AE=BE=E7=BD=AE?= =?UTF-8?q?=20reminder=5Ftimes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 当 repeat_type 不是 none 且 reminder_times 为空时, 自动将当前日期设置为 reminder_times 的第一个元素 Co-Authored-By: Claude Opus 4.6 --- src/routes/events.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/routes/events.ts b/src/routes/events.ts index 5f6acf2..7e09c1e 100644 --- a/src/routes/events.ts +++ b/src/routes/events.ts @@ -156,7 +156,14 @@ router.post( // 如果前端传了 next_reminder_date 就使用它,否则根据 repeat_type 计算 const nextReminderDate = data.next_reminder_date || null; // 存储 reminder_times 为 JSON 字符串 - const reminderTimesValue = data.reminder_times ? JSON.stringify(data.reminder_times) : null; + // 如果有循环类型且 reminder_times 为空,自动设置为 [date] + let reminderTimes = data.reminder_times; + if (!reminderTimes || reminderTimes.length === 0) { + if (data.repeat_type !== 'none' && dateValue) { + reminderTimes = [dateValue]; + } + } + const reminderTimesValue = reminderTimes ? JSON.stringify(reminderTimes) : null; await db.execute({ sql: `INSERT INTO events (id, user_id, type, title, content, date, is_lunar, repeat_type, repeat_interval, next_reminder_date, is_holiday, is_completed, priority, reminder_times, created_at, updated_at)