fix: 创建循环事件时自动设置 reminder_times
当 repeat_type 不是 none 且 reminder_times 为空时, 自动将当前日期设置为 reminder_times 的第一个元素 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
651044f289
commit
16a2c7a043
@ -156,7 +156,14 @@ router.post(
|
|||||||
// 如果前端传了 next_reminder_date 就使用它,否则根据 repeat_type 计算
|
// 如果前端传了 next_reminder_date 就使用它,否则根据 repeat_type 计算
|
||||||
const nextReminderDate = data.next_reminder_date || null;
|
const nextReminderDate = data.next_reminder_date || null;
|
||||||
// 存储 reminder_times 为 JSON 字符串
|
// 存储 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({
|
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)
|
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)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user