fix: 三个 P2 小修(榜单离线兜底/同天连胜文案/热力图日期解析)
- leaderboard.js _applyLocal 离线兜底补 subText(N次),与云端路径对齐 - timer.js _detectCelebrationLevel 增加 lastIsToday 判断,修复同天二次训练连胜文案虚高 1 天 - calendar-heatmap.js 用 util.dateOnly 归一化后再取'日',修复脆弱的 split 解析
This commit is contained in:
@@ -244,7 +244,14 @@ Page({
|
||||
_detectCelebrationLevel(elapsed) {
|
||||
const stats = storage.getTotalStats()
|
||||
const streak = storage.getStreak()
|
||||
const nextStreak = (streak.lastDate && streak.count >= 1) ? streak.count + 1 : 1
|
||||
// 本函数运行在保存记录之前(pre-save state)。updateStreak 对「同一天再次训练」
|
||||
// 会直接 return、不递增连胜数;所以若 streak.lastDate 已是今天,nextStreak 应取
|
||||
// 当前 count 而非 count+1,否则庆祝文案会比真实连胜多 1 天。
|
||||
const todayOnly = storage.getToday().substring(0, 10)
|
||||
const lastIsToday = !!(streak.lastDate && streak.lastDate.substring(0, 10) === todayOnly)
|
||||
const nextStreak = lastIsToday
|
||||
? (streak.count || 1)
|
||||
: ((streak.lastDate && streak.count >= 1) ? streak.count + 1 : 1)
|
||||
|
||||
if (stats.totalSessions === 0) {
|
||||
return { level: 'first', message: '第一次训练!坚持就是胜利' }
|
||||
|
||||
Reference in New Issue
Block a user