From 1d8c71da3f5bd1ece217045c14e8a1617286e627 Mon Sep 17 00:00:00 2001 From: wintsa <770775984@qq.com> Date: Thu, 2 Jan 2025 15:39:36 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=8F=96=E6=B6=88=E8=AF=B7?= =?UTF-8?q?=E6=B1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/cards/MediaCard.vue | 93 ++++++++--------------- src/pages/ranking.vue | 1 + src/router/index.ts | 16 +++- src/views/discover/MediaCardListView.vue | 17 ++--- src/views/discover/MediaCardSlideView.vue | 36 +++++---- yarn.lock | 22 +++++- 6 files changed, 93 insertions(+), 92 deletions(-) diff --git a/src/components/cards/MediaCard.vue b/src/components/cards/MediaCard.vue index 721f8de7..39c68b86 100644 --- a/src/components/cards/MediaCard.vue +++ b/src/components/cards/MediaCard.vue @@ -6,7 +6,7 @@ import { formatSeason } from '@/@core/utils/formatters' import api from '@/api' import { doneNProgress, startNProgress } from '@/api/nprogress' import type { MediaInfo, NotExistMediaInfo, Subscribe, TmdbSeason } from '@/api/types' -import router from '@/router' +import router, { registerAbortController } from '@/router' import noImage from '@images/no-image.jpeg' import tmdbImage from '@images/logos/tmdb.png' import doubanImage from '@images/logos/douban-black.png' @@ -215,6 +215,7 @@ async function removeSubscribe() { // 查询当前媒体是否已订阅 async function handleCheckSubscribe() { try { + const result = await checkSubscribe(props.media?.season) if (result) isSubscribed.value = true } catch (error) { @@ -225,6 +226,11 @@ async function handleCheckSubscribe() { // 查询当前媒体是否已入库 async function handleCheckExists() { try { + let abortController: AbortController | null = null; + + abortController = new AbortController(); + registerAbortController(abortController); + const { signal } = abortController; const result: { [key: string]: any } = await api.get('mediaserver/exists', { params: { tmdbid: props.media?.tmdb_id, @@ -233,6 +239,7 @@ async function handleCheckExists() { season: props.media?.season, mtype: props.media?.type, }, + signal }) if (result.success) isExists.value = true @@ -244,6 +251,11 @@ async function handleCheckExists() { // 调用API检查是否已订阅,电视剧需要指定季 async function checkSubscribe(season = 0) { try { + let abortController: AbortController | null = null; + + abortController = new AbortController(); + registerAbortController(abortController); + const { signal } = abortController; const mediaid = getMediaId() const result: Subscribe = await api.get(`subscribe/media/${mediaid}`, { @@ -251,6 +263,7 @@ async function checkSubscribe(season = 0) { season, title: props.media?.title, }, + signal }) return result.id || null @@ -393,7 +406,7 @@ function setupIntersectionObserver() { } onMounted(() => { - setupIntersectionObserver() + // setupIntersectionObserver() }) onBeforeUnmount(() => { @@ -444,25 +457,13 @@ function onRemoveSubscribe() {