Files
EmailBill/.sisyphus/notepads/calendar-v2-data-loading-fix/decisions.md
SunCheng 1a3d0658bb
All checks were successful
Docker Build & Deploy / Build Docker Image (push) Successful in 20s
Docker Build & Deploy / Deploy to Production (push) Successful in 8s
Docker Build & Deploy / Cleanup Dangling Images (push) Successful in 1s
Docker Build & Deploy / WeChat Notification (push) Successful in 1s
fix
2026-02-04 15:31:22 +08:00

45 lines
1.6 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Calendar V2 数据加载修复 - 决策记录
## 2026-02-04 修复决策
### 问题确认
用户报告:"日历v2中当前月份的日历矩阵中并没有加载当前月份的消费数据"
### 根因分析
1. `Web/src/views/calendarV2/modules/Calendar.vue``fetchAllRelevantMonthsData` 函数
2. 第 144 行在调用 API 时传递的 `month` 参数格式错误
3. JavaScript Date 的 month 是 0-11但后端 API 期望 1-12
4. 上月和下月数据正常,因为代码中已有 `+1` 转换
### 修复方案
**选择:** 在第 144 行添加 `+1` 转换,与上月/下月处理保持一致
**理由:**
- 最小化修改范围仅1行代码 + 1行注释
- 保持代码一致性(三个月份处理逻辑统一)
- 不影响其他功能模块
- 符合现有的API约定
**拒绝的方案:**
- ❌ 修改后端 API 接受 0-11 格式 - 会破坏现有其他调用方
- ❌ 修改 `fetchDailyStats` 函数内部转换 - 会影响所有调用处
- ❌ 使用 watch 监听并重新加载 - 增加不必要的复杂度
### 代码变更
```diff
- const promises = [fetchDailyStats(year, month)]
+ // JavaScript Date.month 是 0-11但后端 API 期望 1-12
+ const promises = [fetchDailyStats(year, month + 1)]
```
### 验证结果
✅ 代码审查通过
✅ ESLint 检查通过0 errors
✅ 逻辑一致性确认(当前月、上月、下月都使用 +1
### 影响范围
- **修改文件:** 仅 `Web/src/views/calendarV2/modules/Calendar.vue`
- **影响功能:** 日历v2 当前月份数据加载
- **用户可见变化:** 当前月份的日期单元格将正确显示消费金额
- **副作用:** 无