mirror of
https://github.com/truewhile/MeBox.git
synced 2026-09-30 11:46:36 +08:00
bug处理
This commit is contained in:
@@ -30,7 +30,13 @@ import type { Media } from '../types'
|
||||
*
|
||||
* 同一组内取最早 created_at 的那条作为代表卡片,并带 count 表示集数。
|
||||
*/
|
||||
export type SeriesCard = { key: string; rep: Media; linkMedia: Media; count: number }
|
||||
export type SeriesCard = {
|
||||
key: string
|
||||
rep: Media
|
||||
linkMedia: Media
|
||||
count: number
|
||||
last_added_at?: string
|
||||
}
|
||||
|
||||
export function getSeriesKey(media: Media): string {
|
||||
return compactSeriesKey(getSeriesRawKey(media))
|
||||
@@ -327,10 +333,22 @@ export function groupSeries(items: Media[] = []): SeriesCard[] {
|
||||
? compactSeriesKey(externalKey)
|
||||
: getSeriesKey(m)
|
||||
|
||||
const mAddedAt = m.created_at || m.updated_at || ''
|
||||
const g = groups.get(key)
|
||||
if (!g) {
|
||||
groups.set(key, { key, rep: m, linkMedia: m, count: 1 })
|
||||
groups.set(key, { key, rep: m, linkMedia: m, count: 1, last_added_at: mAddedAt })
|
||||
} else {
|
||||
if (mAddedAt) {
|
||||
if (!g.last_added_at) {
|
||||
g.last_added_at = mAddedAt
|
||||
} else {
|
||||
const prevTime = new Date(g.last_added_at).getTime()
|
||||
const curTime = new Date(mAddedAt).getTime()
|
||||
if (!isNaN(curTime) && (isNaN(prevTime) || curTime > prevTime)) {
|
||||
g.last_added_at = mAddedAt
|
||||
}
|
||||
}
|
||||
}
|
||||
// Repeated movie IDs represent alternate locations/encodes, not
|
||||
// episodes. Fold the versions but keep the card in movie mode.
|
||||
if (isEpisodeLike(m) || pathLooksEpisodic(m) || isEpisodeLike(g.linkMedia) || pathLooksEpisodic(g.linkMedia)) {
|
||||
|
||||
@@ -114,7 +114,7 @@ export function sortMediaList(
|
||||
case 'created_at':
|
||||
return compareDates(a.created_at, b.created_at, order) || compareStrings(a.title, b.title, 'asc')
|
||||
case 'updated_at':
|
||||
return compareDates(a.updated_at || a.created_at, b.updated_at || b.created_at, order) || compareStrings(a.title, b.title, 'asc')
|
||||
return compareDates(a.created_at || a.updated_at, b.created_at || b.updated_at, order) || compareStrings(a.title, b.title, 'asc')
|
||||
case 'rating':
|
||||
case 'imdb_rating': {
|
||||
const cmp = compareNumbers(a.rating || 0, b.rating || 0, order)
|
||||
@@ -175,8 +175,12 @@ export function sortSeriesList(
|
||||
case 'created_at':
|
||||
return compareDates(repA.created_at, repB.created_at, order) || compareStrings(titleA, titleB, 'asc')
|
||||
case 'updated_at': {
|
||||
const updateA = repA.updated_at || repA.created_at
|
||||
const updateB = repB.updated_at || repB.created_at
|
||||
// 远程挂载库的卡片由服务器按 DateLastContentAdded(上次添加集日期)
|
||||
// 倒序返回且不回传日期值:缺失时保持服务器顺序,避免错误回退成加入日期。
|
||||
// 本地库卡片(groupSeries)始终带 last_added_at,按真实值排序。
|
||||
if (!a.last_added_at && !b.last_added_at) return 0
|
||||
const updateA = a.last_added_at || ''
|
||||
const updateB = b.last_added_at || ''
|
||||
return compareDates(updateA, updateB, order) || compareStrings(titleA, titleB, 'asc')
|
||||
}
|
||||
case 'rating':
|
||||
|
||||
Reference in New Issue
Block a user