Files
yuming ddcfe3334e
部署到群晖 / deploy (push) Successful in 44s
v2.1.0 流程改造 + 农历准确性修复 + 双向同步 + 闰月支持
- Phase 1: 添加纪念日合并人物创建流程(方案 B)
- Phase 2: 农历提醒按 lunarMonth/Day 计算每年公历
- Phase 3: 人员数据同步到后端(新增 /api/person)
- Phase 4: 新设备启动从云端恢复数据
- Phase 5: 工具函数收敛 utils/format.js
- Phase 6: 同步失败入队 + 启动重试
- Phase 7: 闰月生日完整支持(含 isLeapMonth + UI 警示)
- 修复 lunarInfo 数据表错位(替换为权威源 jjonline/calendar.js)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-06-02 05:51:17 +08:00

36 lines
938 B
JavaScript

/**
* 纪念日相关的展示格式化工具
* Why:原本散落在 index / person-detail / add-anniversary 里的转换逻辑,统一到这里避免多份维护
*/
const { TYPE_NAMES, TYPE_ICONS, IMPORTANCE_TEXTS } = require('./constants')
function getTypeName(type, customTypeName) {
if (type === 'other' && customTypeName) return customTypeName
return TYPE_NAMES[type] || '纪念日'
}
function getTypeIcon(type) {
return TYPE_ICONS[type] || '📅'
}
function getImportanceText(importance) {
return IMPORTANCE_TEXTS[importance] || '一般'
}
// 距离 X 天的口语化展示
function formatDaysUntil(days) {
if (days === 0) return '今天'
if (days === 1) return '明天'
if (days < 7) return `${days}天后`
if (days < 30) return `还有${Math.floor(days / 7)}`
return `还有${Math.floor(days / 30)}个月`
}
module.exports = {
getTypeName,
getTypeIcon,
getImportanceText,
formatDaysUntil
}