From 2829e3b08214348f05ff2f5beae644882eccad58 Mon Sep 17 00:00:00 2001 From: InfinityPacer <160988576+InfinityPacer@users.noreply.github.com> Date: Mon, 15 Jun 2026 15:54:08 +0800 Subject: [PATCH] fix(subscribe): display special season labels (#491) --- scripts/check-season-label.ts | 12 ++++++++++++ src/@core/utils/season.ts | 15 +++++++++++++++ src/components/cards/SubscribeCard.vue | 5 +++-- src/locales/en-US.ts | 1 + src/locales/zh-CN.ts | 1 + src/locales/zh-TW.ts | 1 + src/views/discover/MediaDetailView.vue | 6 ++++-- 7 files changed, 37 insertions(+), 4 deletions(-) create mode 100644 scripts/check-season-label.ts create mode 100644 src/@core/utils/season.ts diff --git a/scripts/check-season-label.ts b/scripts/check-season-label.ts new file mode 100644 index 00000000..f758e59b --- /dev/null +++ b/scripts/check-season-label.ts @@ -0,0 +1,12 @@ +import assert from 'node:assert/strict' + +import { formatSeasonLabel } from '../src/@core/utils/season.ts' + +assert.equal(formatSeasonLabel(0, '特别篇'), '特别篇') +assert.equal(formatSeasonLabel('0', 'Specials'), 'Specials') +assert.equal(formatSeasonLabel(1, '特别篇'), 'S01') +assert.equal(formatSeasonLabel('12', '特别篇'), 'S12') +assert.equal(formatSeasonLabel(null, '特别篇'), '') +assert.equal(formatSeasonLabel(undefined, '特别篇'), '') + +console.log('season label checks passed') diff --git a/src/@core/utils/season.ts b/src/@core/utils/season.ts new file mode 100644 index 00000000..11e644be --- /dev/null +++ b/src/@core/utils/season.ts @@ -0,0 +1,15 @@ +/** + * 格式化用户可见的季标签。 + * + * TMDB 使用季号 0 表示特别季;调用方传入当前语言的特别季名称, + * 其余季号保持 MoviePilot 现有的 Sxx 展示口径。 + */ +export function formatSeasonLabel( + season: number | string | null | undefined, + specialsLabel: string, +): string { + if (season === null || season === undefined || season === '') return '' + if (Number(season) === 0) return specialsLabel + + return `S${String(season).padStart(2, '0')}` +} diff --git a/src/components/cards/SubscribeCard.vue b/src/components/cards/SubscribeCard.vue index 5b2f4f13..8f7f7489 100644 --- a/src/components/cards/SubscribeCard.vue +++ b/src/components/cards/SubscribeCard.vue @@ -1,7 +1,8 @@