From d4548db5b98a45b390539fa244119adba3557aab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=99=AF=E5=A4=A7=E4=BE=A0?= Date: Fri, 6 Feb 2026 12:40:05 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=AE=8C=E5=96=84=E5=87=A0=E5=A4=84S00?= =?UTF-8?q?=E8=AE=A2=E9=98=85=E7=9B=B8=E5=85=B3=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/cards/MediaCard.vue | 10 +++++----- src/views/discover/MediaDetailView.vue | 22 +++++++++++----------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/components/cards/MediaCard.vue b/src/components/cards/MediaCard.vue index 73e34c30..2af9919f 100644 --- a/src/components/cards/MediaCard.vue +++ b/src/components/cards/MediaCard.vue @@ -138,7 +138,7 @@ async function handleAddSubscribe() { } // 调用API添加订阅,电视剧的话需要指定季 -async function addSubscribe(season: number | null = 0, best_version: number = 0) { +async function addSubscribe(season: number | null = null, best_version: number = 0) { // 开始处理 startNProgress() try { @@ -184,7 +184,7 @@ async function addSubscribe(season: number | null = 0, best_version: number = 0) // 弹出添加订阅提示 function showSubscribeAddToast(result: boolean, title: string, season: number | null, message: string, best_version: number) { - if (season) title = `${title} ${formatSeason(season.toString())}` + if (season !== null) title = `${title} ${formatSeason(season.toString())}` let subname = t('subscribe.normalSub') if (best_version > 0) subname = t('subscribe.versionSub') @@ -222,7 +222,7 @@ async function removeSubscribe() { // 查询当前媒体是否已订阅 async function handleCheckSubscribe() { try { - const result = await checkSubscribe(props.media?.season) + const result = await checkSubscribe(props.media?.season ?? null) if (result) isSubscribed.value = true } catch (error) { console.error(error) @@ -249,7 +249,7 @@ async function handleCheckExists() { } // 调用API检查是否已订阅,电视剧需要指定季 -async function checkSubscribe(season = 0) { +async function checkSubscribe(season: number | null) { try { // AbortController 现在由全局请求优化器自动管理 const mediaid = getMediaId() @@ -300,7 +300,7 @@ function subscribeSeasons(seasons: MediaSeason[], seasonNoExists: { [key: number if (season && props.media?.tmdb_id) // 全部存在时洗版 best_version = !seasonNoExists[season.season_number || 0] ? 1 : 0 - addSubscribe(season.season_number, best_version) + addSubscribe(season.season_number ?? null, best_version) }) } diff --git a/src/views/discover/MediaDetailView.vue b/src/views/discover/MediaDetailView.vue index 1a28ee62..c3603852 100644 --- a/src/views/discover/MediaDetailView.vue +++ b/src/views/discover/MediaDetailView.vue @@ -190,7 +190,7 @@ async function checkExists() { } // 查询当前媒体是否已订阅 -async function checkSubscribe(season = 0) { +async function checkSubscribe(season: number | null = null) { try { const mediaid = getMediaId() @@ -249,7 +249,7 @@ async function checkSeasonsSubscribed() { if (mediaDetail.value.type !== '电视剧') return try { mediaDetail.value?.season_info?.forEach(async item => { - seasonsSubscribed.value[item.season_number ?? 0] = await checkSubscribe(item.season_number) + seasonsSubscribed.value[item.season_number ?? 0] = await checkSubscribe(item.season_number ?? null) }) } catch (error) { console.error(error) @@ -257,13 +257,13 @@ async function checkSeasonsSubscribed() { } // 调用API添加订阅,电视剧的话需要指定季 -async function addSubscribe(season: number | null = 0) { +async function addSubscribe(season: number | null) { // 开始处理 startNProgress() try { // 是否洗版 let best_version = existsItemId.value ? 1 : 0 - if (season) + if (season !== null) // 全部存在时洗版 best_version = !seasonsNotExisted.value[season] ? 1 : 0 // 请求API @@ -282,7 +282,7 @@ async function addSubscribe(season: number | null = 0) { if (result.success) { // 订阅成功 isSubscribed.value = true - if (season) seasonsSubscribed.value[season] = true + if (season !== null) seasonsSubscribed.value[season] = true } // 提示 @@ -304,7 +304,7 @@ async function addSubscribe(season: number | null = 0) { // 弹出添加订阅提示 function showSubscribeAddToast(result: boolean, title: string, season: number | null, message: string, best_version: number) { - if (season) title = `${title} ${formatSeason(season.toString())}` + if (season !== null) title = `${title} ${formatSeason(season.toString())}` let subname = t('media.subscribe.normal') if (best_version > 0) subname = t('media.subscribe.bestVersion') @@ -313,7 +313,7 @@ function showSubscribeAddToast(result: boolean, title: string, season: number | } // 调用API取消订阅 -async function removeSubscribe(season: number) { +async function removeSubscribe(season: number | null) { // 开始处理 startNProgress() try { @@ -327,7 +327,7 @@ async function removeSubscribe(season: number) { if (result.success) { isSubscribed.value = false - if (season) seasonsSubscribed.value[season] = false + if (season !== null) seasonsSubscribed.value[season] = false $toast.success(`${mediaDetail.value?.title} ${t('media.subscribe.canceled')}`) } else { $toast.error(`${mediaDetail.value?.title} ${t('media.subscribe.cancelFailed', { reason: result.message })}`) @@ -339,7 +339,7 @@ async function removeSubscribe(season: number) { } // 订阅按钮响应 -function handleSubscribe(season = 0) { +function handleSubscribe(season: number | null = null) { if (isSubscribed.value) removeSubscribe(season) else addSubscribe(season) } @@ -647,7 +647,7 @@ onBeforeMount(() => { class="ms-2 mb-2" :color="getSubscribeColor" variant="tonal" - @click="handleSubscribe(0)" + @click="handleSubscribe()" >