refactor: 清理死代码 + 提前失败 + 错误记录控制台
- 移除 EventDetail.vue 未用的 computed 导入 - 移除 HeaderBar.vue 未用的 .btn-secondary CSS - store (updateEvent/splitEvent/toggleOccurrence): uid 缺失改抛错 (fail-fast), 不再静默 return - EventDetail onSplit: 捕获 splitEvent 抛错并提示用户 - DropZone/HeaderBar 解析失败: catch 内补 console.error - ical-io getZone: 时区未注册回退 UTC 时 console.warn - WeekPreview 周标签改用 i18n (weekPreview.rangeFmt), 与 MonthPreview 一致 - docs: 新增 error-handling.md; 修正 auto-save-design state 快照补 timezone - README: 补充部署说明 (经 zMainPage apache2 托管)
This commit is contained in:
25
docs/error-handling.md
Normal file
25
docs/error-handling.md
Normal file
@@ -0,0 +1,25 @@
|
||||
# 错误处理与日志约定
|
||||
|
||||
timeTableFix 的错误处理分两层:纯库函数 fail-fast,UI 层捕获后既写控制台又给用户反馈。
|
||||
|
||||
## 纯库层(src/lib/)
|
||||
|
||||
- 解析/算法错误直接抛出或返回 `null`,由调用方决定如何反馈。
|
||||
- `parseICS`:`ICAL.parse` 对非法文本抛错,向上传播。
|
||||
- `splitRecurringEvent` / `fitSeries`:不可处理时返回 `null`(合法的「拒绝」语义)。
|
||||
- `getZone`:时区未注册(VTIMEZONE 缺失)时回退 UTC 并 `console.warn`,避免静默时间偏移。
|
||||
|
||||
## store 层(src/composables/useCalendar.js)
|
||||
|
||||
- `loadFile`:不吞错,`parseICS` 的异常直接 reject 给调用方。
|
||||
- `updateEvent` / `splitEvent` / `toggleOccurrence`:uid 不存在视为编程错误,**抛错**而非静默 return。调用方(EventDetail)在调前已校验 `selectedEvent`,正常流程不会触发;触发即暴露 bug。
|
||||
|
||||
## UI 层(src/components/)
|
||||
|
||||
- 文件解析失败(DropZone / HeaderBar):`.catch` 内 `console.error` 记录原始错误,再用 `alert` 告知用户。
|
||||
- 拆分失败(EventDetail `onSplit`):`splitEvent` 抛错被 `try/catch` 捕获,`console.error` + 提示日期无效。
|
||||
- 时区检测/列表降级(timezone.js):旧环境 `Intl` 不可用时静默回退墨尔本(有测试覆盖),属可接受的降级。
|
||||
|
||||
## 控制台前缀
|
||||
|
||||
所有 `[timeTableFix]` 前缀的日志均来自本子项目,便于在嵌入宿主时与宿主日志区分。
|
||||
Reference in New Issue
Block a user