diff --git a/src/api/types.ts b/src/api/types.ts index 912d431d..1a51af48 100644 --- a/src/api/types.ts +++ b/src/api/types.ts @@ -193,6 +193,9 @@ export interface MediaInfo { // 详情页面 detail_link?: string + // 季详情 + season_info?: TmdbSeason[] + // 导演 directors?: any[] diff --git a/src/views/discover/MediaDetailView.vue b/src/views/discover/MediaDetailView.vue index affd0192..06a72c1a 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, Subscribe } from '@/api/types' +import type { MediaInfo, Subscribe, TmdbEpisode } from '@/api/types' import NoDataFound from '@/components/NoDataFound.vue' // 输入参数 @@ -23,6 +23,9 @@ const isSubscribed = ref(false) // 是否已加载完成 const isRefreshed = ref(false) +// 存储每一季的集信息 +const seasonEpisodesInfo = ref({} as { [key: number]: TmdbEpisode[] }) + // 调用API查询详情 async function getMediaDetail() { if (mediaProps.mediaid && mediaProps.type) { @@ -39,6 +42,20 @@ async function getMediaDetail() { } } +// 调用API加载季集信息 +async function loadSeasonEpisodes(season: number) { + if (seasonEpisodesInfo.value[season]) + return + + try { + const result: TmdbEpisode[] = await api.get(`tmdb/${mediaDetail.value.tmdb_id}/${season}`) + seasonEpisodesInfo.value[season] = result || [] + } + catch (error) { + console.error(error) + } +} + // 查询当前媒体是否已存在 async function checkExists() { try { @@ -107,6 +124,13 @@ function getTvdbLink() { return `https://www.thetvdb.com/series/${mediaDetail.value.tvdb_id}` } +// 拼装集图片地址 +function getEpisodeImage(stillPath: string) { + if (!stillPath) + return '' + return `https://image.tmdb.org/t/p/w500${stillPath}` +} + // 获取发行国家名称 const getProductionCountries = computed(() => { return mediaDetail.value.production_companies?.map(country => country.name) @@ -159,7 +183,7 @@ onBeforeMount(() => { 播放 - + 订阅 @@ -205,6 +229,61 @@ onBeforeMount(() => { +

+ 季 +

+
+ + + + + + + + + + +