修复 P0 五个问题,版本号 v2.1.6 → v2.1.7
1. 删除纪念日不同步云端:storage.deleteAnniversary 只删本地,后端记录仍是
remindEnabled=1,定时任务会继续推已删除的纪念日,换设备恢复时还会被拉回来。
补上 _syncAnniversary('delete')。
2. 农历纪念日日期计算三处口径不一:date.js 新增 getOccurrenceInYear /
getNextOccurrenceOf,首页、详情页、日历页统一复用。
顺带修掉一个隐藏更深的坑——老实现把公历年当农历年传给 lunarToSolar,
农历腊月会整整错一年(农历2026腊月十五 = 公历2027-01-22,老算法给 2028-01-11)。
新实现同时试 year-1 / year 两个农历年,取真正落在该公历年内的那次。
删除已无调用方的旧 getNextOccurrence(month, day),它正是首页 bug 的来源。
3. 详情页倒计时永远显示「已过 N 天」:原先按录入年份算 daysUntil,
改为按下一次发生算;「日期」一行仍展示原始录入日期。
4. 日历页切 tab 后不刷新:渲染从 onLoad 挪到 onShow(tabBar 页面实例常驻),
不重置当前年月,保留用户翻到的月份。
5. 清空数据后重启会复活:只清本地的话 pullFromCloudIfEmpty 会把云端整份拉回来。
新增 storage.clearCloudData()(sync 传空数组),设置页改为先清云端、
成功才清本地;云端失败则中止并提示,本地数据保留。
均为小程序侧改动,server/ 未改动,无需重新部署。
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
+27
-16
@@ -19,7 +19,7 @@ Page({
|
||||
personsCount: 0,
|
||||
anniversariesCount: 0,
|
||||
lastBackupText: '从未备份',
|
||||
version: 'v2.1.6'
|
||||
version: 'v2.1.7'
|
||||
},
|
||||
|
||||
onLoad() {
|
||||
@@ -92,23 +92,34 @@ Page({
|
||||
onClearData() {
|
||||
wx.showModal({
|
||||
title: '确认清空',
|
||||
content: '确定要清空所有数据吗?此操作不可恢复!',
|
||||
content: '本地和云端备份都会被清空,此操作不可恢复!',
|
||||
confirmText: '确认清空',
|
||||
confirmColor: '#C8412F',
|
||||
success: (res) => {
|
||||
if (res.confirm) {
|
||||
const success = storage.clearAllData()
|
||||
if (success) {
|
||||
wx.showToast({
|
||||
title: '已清空',
|
||||
icon: 'success'
|
||||
})
|
||||
setTimeout(() => {
|
||||
wx.reLaunch({
|
||||
url: '/pages/index/index'
|
||||
})
|
||||
}, 1500)
|
||||
}
|
||||
success: async (res) => {
|
||||
if (!res.confirm) return
|
||||
|
||||
// 先清云端再清本地:顺序反了的话,本地清空后下次启动会从云端把数据整份拉回来
|
||||
wx.showLoading({ title: '正在清空...', mask: true })
|
||||
const cloud = await storage.clearCloudData()
|
||||
wx.hideLoading()
|
||||
|
||||
if (!cloud.success) {
|
||||
// 云端没清干净就不动本地,否则会出现「清了又自己回来」的诡异现象
|
||||
wx.showModal({
|
||||
title: '清空失败',
|
||||
content: `云端数据未能清除(${cloud.error}),本地数据已保留。请检查网络后重试。`,
|
||||
showCancel: false
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
if (storage.clearAllData()) {
|
||||
wx.showToast({ title: '已清空', icon: 'success' })
|
||||
setTimeout(() => {
|
||||
wx.reLaunch({ url: '/pages/index/index' })
|
||||
}, 1500)
|
||||
} else {
|
||||
wx.showToast({ title: '本地清空失败,请重试', icon: 'none' })
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user