From 9a27ebbea1d1debe1a7c9a6f3fdc937927b61059 Mon Sep 17 00:00:00 2001 From: jxxghp Date: Wed, 2 Aug 2023 11:54:02 +0800 Subject: [PATCH] fix --- src/api/types.ts | 2 +- src/views/discover/MediaDetailView.vue | 81 ++++++++++++++++++++++++-- 2 files changed, 78 insertions(+), 5 deletions(-) diff --git a/src/api/types.ts b/src/api/types.ts index c7300825..2cd0e053 100644 --- a/src/api/types.ts +++ b/src/api/types.ts @@ -221,7 +221,7 @@ export interface MediaInfo { vote_count?: number popularity?: number runtime?: number - next_episode_to_air?: string + next_episode_to_air?: object } // TMDB季信息 diff --git a/src/views/discover/MediaDetailView.vue b/src/views/discover/MediaDetailView.vue index e39d6460..7507c011 100644 --- a/src/views/discover/MediaDetailView.vue +++ b/src/views/discover/MediaDetailView.vue @@ -2,7 +2,7 @@ import PersonCardSlideView from './PersonCardSlideView.vue' import MediaCardSlideView from './MediaCardSlideView.vue' import api from '@/api' -import type { MediaInfo } from '@/api/types' +import type { MediaInfo, Subscribe } from '@/api/types' import NoDataFound from '@/components/NoDataFound.vue' // 输入参数 @@ -17,6 +17,9 @@ const mediaDetail = ref({} as MediaInfo) // 本地是否存在 const isExists = ref(false) +// 是否已订阅 +const isSubscribed = ref(false) + // 是否已加载完成 const isRefreshed = ref(false) @@ -31,6 +34,8 @@ async function getMediaDetail() { isRefreshed.value = true // 检查存在状态 checkExists() + // 检查订阅状态 + checkSubscribe() } } @@ -55,11 +60,53 @@ async function checkExists() { } } +// 查询当前媒体是否已订阅 +async function checkSubscribe(season = 0) { + try { + const mediaid = `tmdb:${mediaDetail.value.tmdb_id}` + + const result: Subscribe = await api.get(`subscribe/media/${mediaid}`, { + params: { + season, + }, + }) + + if (result.id) + isSubscribed.value = true + } + catch (error) { + console.error(error) + } + + return null +} + // 从genres中获取name,使用、分隔 function getGenresName(genres: any[]) { return genres.map(genre => genre.name).join('、') } +// 拼装TheMovieDb地址 +function getTheMovieDbLink() { + const mtype = mediaProps.type === '电影' ? 'movie' : 'tv' + return `https://www.themoviedb.org/${mtype}/${mediaDetail.value.tmdb_id}` +} + +// 拼装豆瓣地址 +function getDoubanLink() { + return `https://movie.douban.com/subject/${mediaDetail.value.douban_id}` +} + +// 拼装IMDB地址 +function getImdbLink() { + return `https://www.imdb.com/title/${mediaDetail.value.imdb_id}` +} + +// 拼装TVDB地址 +function getTvdbLink() { + return `https://www.thetvdb.com/series/${mediaDetail.value.tvdb_id}` +} + onBeforeMount(() => { getMediaDetail() }) @@ -94,15 +141,15 @@ onBeforeMount(() => { {{ mediaDetail.runtime }} 分钟 - | + | {{ getGenresName(mediaDetail.genres || []) }}
- + 播放 - + 订阅
@@ -122,6 +169,32 @@ onBeforeMount(() => { {{ director.name }} +