fix: 观看进度上报保留长整型剧集ID字符串,避免精度丢失导致记录写入失败

This commit is contained in:
Zhou Weidong committed 2026-11-11 18:17:23 +08:00
1 parent eced2890ae
commit cef39e96c0
1 file changed
+3 -2
+3 -2
View File
@@ -5,8 +5,9 @@ const REPORT_INTERVAL_MS = 10000;
const lastReportedAt = new Map();
export function reportWatchProgress(episodeId, positionSeconds, durationSeconds, source = 'web', force = false) {
const id = Number(episodeId);
if (!Number.isFinite(id) || id <= 0) return;
// 剧集 ID 为 19 位长整型,超出 JS 安全整数范围,必须保持字符串,禁止 Number 转换
const id = String(episodeId ?? '');
if (!/^\d+$/.test(id)) return;
const now = Date.now();
if (!force && now - (lastReportedAt.get(id) || 0) < REPORT_INTERVAL_MS) return;
lastReportedAt.set(id, now);