倒数日模块
倒数日模块管理重要的日期提醒。
数据结构
interface CountdownItem {
id: string
name: string // 名称
targetDate: string // 目标日期 (YYYY-MM-DD)
repeatType: 'none' | 'monthly' | 'yearly' // 重复类型
repeatInterval: number // 重复间隔
createdAt: string
}
IPC 通道
| 通道 | 参数 | 返回 |
|---|---|---|
countdown-get-all | - | CountdownItem[] |
countdown-create | Partial<CountdownItem> | CountdownItem |
countdown-update | id, Partial<CountdownItem> | CountdownItem |
countdown-delete | id | boolean |
日期计算逻辑
不重复
直接计算目标日期与今天的差值。
每月重复
从目标日期开始,按 repeatInterval 个月递增,找到 >= 今天的第一个日期。
每年重复
从目标日期开始,按 repeatInterval 年递增,找到 >= 今天的第一个日期。
排序规则
- 今天(days === 0)排最前
- 未来日期按天数升序
- 已过日期排最后