From efc7e17075a3967b270e3d69b1aa8d6234d1e096 Mon Sep 17 00:00:00 2001 From: x1ao4 Date: Wed, 17 Sep 2025 01:30:10 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BB=BB=E5=8A=A1=E8=BF=9B?= =?UTF-8?q?=E5=BA=A6=E6=8E=92=E5=BA=8F=E9=80=BB=E8=BE=91=EF=BC=8C=E5=8A=A0?= =?UTF-8?q?=E5=85=A5=E8=8A=82=E7=9B=AE=E7=8A=B6=E6=80=81=E3=80=81=E6=92=AD?= =?UTF-8?q?=E5=87=BA=E8=BF=9B=E5=BA=A6=E3=80=81=E8=8A=82=E7=9B=AE=E6=80=BB?= =?UTF-8?q?=E9=9B=86=E6=95=B0=E7=AD=89=E5=A4=9A=E7=BA=A7=E6=AF=94=E8=BE=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 进度排序(by=progress)改为四层比较,且全部随升/降序方向变化: 1) 任务进度百分比(已转存/已播出) 2) 节目状态优先级:播出中/无 < 本季终 < 已取消 < 已完结 3) 播出进度百分比(已播出/总集数),在相同进度下进一步排序 3.1) 若百分比也相同,则按总集数比较(例如 12/12 < 22/22 < 36/36) 4) 任务编号(#XX),用于完全相同时的最终稳定排序 - 状态取值沿用现有逻辑:仅显示并参与排序的状态为「本季终 / 已取消 / 已完结」,其余视为 “无状态” - 保持与现有数据源兼容:进度、状态与播出统计基于 calendar.tasks/season_counts 及映射函数获取 - 所有层级比较通过统一 factor 输出,确保与用户选择的升/降序一致 --- app/templates/index.html | 55 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 54 insertions(+), 1 deletion(-) diff --git a/app/templates/index.html b/app/templates/index.html index 476acaa..5e44741 100644 --- a/app/templates/index.html +++ b/app/templates/index.html @@ -3877,7 +3877,60 @@ } else if (by === 'progress') { const ap = (this.getTaskProgress && this.getTaskProgress(a.t.taskname) != null) ? Number(this.getTaskProgress(a.t.taskname)) : -1; const bp = (this.getTaskProgress && this.getTaskProgress(b.t.taskname) != null) ? Number(this.getTaskProgress(b.t.taskname)) : -1; - cmp = ap - bp; + // 1) 主排序:任务进度(支持升降序) + const pDiff = ap - bp; + if (pDiff !== 0) { + cmp = pDiff; + } else { + // 2) 次排序:节目状态优先级(与主排序方向一致,通过最终 factor 生效) + const getStatusPriority = (task) => { + try { + // 任务对象可能为任务配置,需要先从日历任务映射中取状态 + const calTask = this.getCalendarTaskByName(task && (task.taskname || task.task_name)); + const status = this.getTaskShowStatus(calTask || task) || ''; + if (status === '本季终') return 1; + if (status === '已取消') return 2; + if (status === '已完结') return 3; + return 0; // 播出中/无状态 + } catch (e) { return 0; } + }; + const aStatus = getStatusPriority(a.t); + const bStatus = getStatusPriority(b.t); + const sDiff = aStatus - bStatus; + if (sDiff !== 0) { + cmp = sDiff; // 顺序:播出中/无 < 本季终 < 已取消 < 已完结(方向由最终 factor 决定) + } else { + // 3) 三次排序:节目的播出进度(已播出/总集数),与主排序同方向 + const getBroadcastPct = (task) => { + try { + const calTask = this.getCalendarTaskByName(task && (task.taskname || task.task_name)); + const aired = this.getTaskAiredCount(calTask || {}); + const total = this.getTaskTotalCount(calTask || {}); + if (!total || total <= 0) return 0; + return aired / total; + } catch (e) { return 0; } + }; + const aPct = getBroadcastPct(a.t); + const bPct = getBroadcastPct(b.t); + const pctDiff = aPct - bPct; + if (pctDiff !== 0) { + cmp = pctDiff; + } else { + // 3.1) 百分比也相同:按节目总集数排序(与主排序同方向) + const aTotal = this.getTaskTotalCount(this.getCalendarTaskByName(a.t && (a.t.taskname || a.t.task_name)) || {}); + const bTotal = this.getTaskTotalCount(this.getCalendarTaskByName(b.t && (b.t.taskname || b.t.task_name)) || {}); + const totalDiff = aTotal - bTotal; + if (totalDiff !== 0) { + cmp = totalDiff; + } else { + // 4) 末级排序:任务编号(#XX),与主排序同方向 + const aNum = parseInt((a.t.taskname || '').match(/^#?(\d+)/)?.[1] || '0'); + const bNum = parseInt((b.t.taskname || '').match(/^#?(\d+)/)?.[1] || '0'); + cmp = aNum - bNum; + } + } + } + } } else if (by === 'update_time') { // 按任务最近转存时间排序 const aRecord = this.taskLatestRecords[a.t.taskname];