fix: 修复审查发现的 4 个高优先级问题
- plan: getTodayTarget 补 customPlans 参数,timer/index 调用点传值,修复自定义计划每日目标失效 - leaderboard: fetchRank 加请求序列号丢弃过期响应,修复快速切换周期竞态 - leaderboard 云函数:遍历记录加防御(r.date/duration/数组校验),避免单条脏数据崩溃全榜 - tts: _upload cloudPath 补 volume/speed,避免不同音量语速音频互相覆盖 Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -107,15 +107,21 @@ exports.main = async (event) => {
|
||||
|
||||
for (const monthKey of Object.keys(records)) {
|
||||
if (prefix && !monthKey.startsWith(prefix)) continue
|
||||
for (const r of records[monthKey]) {
|
||||
const arr = records[monthKey]
|
||||
if (!Array.isArray(arr)) continue
|
||||
for (const r of arr) {
|
||||
// 防御脏数据:r.date 缺失/非字符串、duration 非数字时跳过,
|
||||
// 避免单条坏记录抛 TypeError 导致整个排行榜对所有人失败
|
||||
if (!r || typeof r.date !== 'string') continue
|
||||
const dur = Number(r.duration) || 0
|
||||
if (period === 'day') {
|
||||
// Use startsWith rather than === to tolerate date strings with
|
||||
// trailing time/zone info (e.g. "2026-06-11T09:11:24.587Z" if
|
||||
// some legacy path stored an ISO date) and to be timezone-
|
||||
// agnostic when client local date differs from server UTC date.
|
||||
if (r.date.startsWith(exact)) { duration += r.duration; sessions++ }
|
||||
if (r.date.startsWith(exact)) { duration += dur; sessions++ }
|
||||
} else {
|
||||
if (r.date.startsWith(prefix)) { duration += r.duration; sessions++ }
|
||||
if (r.date.startsWith(prefix)) { duration += dur; sessions++ }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user