修复任务列表列表视图下的集数统计问题

- 修复 getTaskSeasonCounts 函数,使其支持 progressByTaskName 映射
- 支持基于日期的集数统计,与海报视图保持一致
- 修复排序逻辑中的集数计算问题
- 确保列表视图和海报视图的集数统计数据一致

问题:任务列表列表视图下没有正确获取基于日期的集数统计,排序时也被视作0
解决:让 getTaskSeasonCounts 函数优先使用 progressByTaskName 映射,支持基于日期的集数查找
This commit is contained in:
x1ao4 2025-09-15 02:00:19 +08:00
parent 9e717f1b69
commit e1a3a74752

View File

@ -3983,7 +3983,34 @@
const t = this.calendar.tasks.find(x => (x.task_name || x.taskname) === taskName); const t = this.calendar.tasks.find(x => (x.task_name || x.taskname) === taskName);
if (!t || !t.season_counts) return null; if (!t || !t.season_counts) return null;
const sc = t.season_counts || {}; const sc = t.season_counts || {};
const transferred = Number(sc.transferred_count || 0);
// 优先使用 progressByTaskName 映射获取已转存集数(支持基于日期的集数统计)
let transferred = Number(sc.transferred_count || 0);
const byTask = this.calendar && this.calendar.progressByTaskName ? this.calendar.progressByTaskName : {};
if (byTask[taskName]) {
const prog = byTask[taskName] || {};
if (prog.episode_number != null) {
transferred = Number(prog.episode_number) || 0;
} else if (prog.air_date) {
// 仅有日期直接在本地DB剧集里找到"该节目在该日期播出的那一集"的集号
const showName = (t.matched_show_name || t.show_name || '').trim();
if (showName && Array.isArray(this.calendar.episodes) && this.calendar.episodes.length > 0) {
const date = String(prog.air_date).trim();
// 找到该节目在该日期播出的所有集,取最大集号作为"已转存集数"
const candidates = this.calendar.episodes.filter(e => {
return e && (e.show_name || '').trim() === showName && (e.air_date || '').trim() === date;
});
if (candidates.length > 0) {
const maxEp = candidates.reduce((m, e) => {
const n = parseInt(e.episode_number);
return isNaN(n) ? m : Math.max(m, n);
}, 0);
if (maxEp > 0) transferred = maxEp;
}
}
}
}
const aired = Number(sc.aired_count || 0); const aired = Number(sc.aired_count || 0);
const total = Number(sc.total_count || 0); const total = Number(sc.total_count || 0);
if (transferred === 0 && aired === 0 && total === 0) return null; if (transferred === 0 && aired === 0 && total === 0) return null;