From 48749b29febefeec1792731c8606d29dcc689409 Mon Sep 17 00:00:00 2001 From: jxxghp Date: Sat, 22 Jul 2023 11:50:13 +0800 Subject: [PATCH] =?UTF-8?q?feat=20=E6=9C=AC=E5=9C=B0=E5=AD=98=E5=9C=A8?= =?UTF-8?q?=E6=A0=87=E8=AF=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/cards/MediaCard.vue | 34 +++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/src/components/cards/MediaCard.vue b/src/components/cards/MediaCard.vue index c888eee0..7769d386 100644 --- a/src/components/cards/MediaCard.vue +++ b/src/components/cards/MediaCard.vue @@ -27,6 +27,9 @@ const tmdbFlag = ref(true); // 当前订阅状态 const isSubscribed = ref(false); +// 本地存在状态 +const isExists = ref(false); + // 各季缺失状态:0-已存在 1-部分缺失 2-全部缺失 const seasonsNotExisted = ref<{ [key: number]: number }>({}); @@ -197,6 +200,26 @@ const handleCheckSubscribe = async () => { } }; +// 查询当前媒体是否已存在 +const handleCheckExists = async () => { + try { + const result: {[key:string]: any} = await api.get(`media/exists`, { + params: { + tmdbid: props.media?.tmdb_id, + title: props.media?.title, + year: props.media?.year, + season: props.media?.season, + mtype: props.media?.type, + }, + }); + if (result.success) { + isExists.value = true; + } + } catch (error) { + console.error(error); + } +}; + // 调用API检查是否已订阅,电视剧需要指定季 const checkSubscribe = async (season: number = 0) => { try { @@ -337,7 +360,10 @@ const handleSearch = () => { }; // 装载时检查是否已订阅 -onBeforeMount(handleCheckSubscribe); +onBeforeMount(() => { + handleCheckSubscribe(); + handleCheckExists(); +}); // 订阅季表头 const seasonsHeaders = [ @@ -396,11 +422,13 @@ const getImgUrl = (url: string) => { > {{ props.media?.type }} + + @@ -442,7 +470,7 @@ const getImgUrl = (url: string) => { > - +