feat:在媒体相关组件中添加媒体ID、标题和年份的支持

This commit is contained in:
jxxghp
2025-02-06 20:33:14 +08:00
parent 673596d8f9
commit b642eabbb3
8 changed files with 62 additions and 13 deletions
+4
View File
@@ -14,6 +14,10 @@ export interface Subscribe {
tmdbid: number tmdbid: number
// 豆瓣ID // 豆瓣ID
doubanid?: string doubanid?: string
// Bangumi ID
bangumiid?: string
// 其它媒体ID
mediaid?: string
// 季号 // 季号
season?: number season?: number
// 海报 // 海报
+4
View File
@@ -363,6 +363,8 @@ function goMediaDetail(isHovering = false) {
path: '/media', path: '/media',
query: { query: {
mediaid: getMediaId(), mediaid: getMediaId(),
title: props.media?.title,
year: props.media?.year,
type: props.media?.type, type: props.media?.type,
}, },
}) })
@@ -378,6 +380,8 @@ function handleSearch() {
keyword: getMediaId(), keyword: getMediaId(),
type: props.media?.type, type: props.media?.type,
area: 'title', area: 'title',
title: props.media?.title,
year: props.media?.year,
season: props.media?.season, season: props.media?.season,
}, },
}) })
+11 -1
View File
@@ -142,12 +142,22 @@ async function editSubscribeDialog() {
subscribeEditDialog.value = true subscribeEditDialog.value = true
} }
// 获得mediaid
function getMediaId() {
if (props.media?.tmdbid) return `tmdb:${props.media?.tmdbid}`
else if (props.media?.doubanid) return `douban:${props.media?.doubanid}`
else if (props.media?.bangumiid) return `bangumi:${props.media?.bangumiid}`
else return props.media?.mediaid
}
// 查看媒体详情 // 查看媒体详情
async function viewMediaDetail() { async function viewMediaDetail() {
router.push({ router.push({
path: '/media', path: '/media',
query: { query: {
mediaid: `${props.media?.tmdbid ? `tmdb:${props.media?.tmdbid}` : `douban:${props.media?.doubanid}`}`, mediaid: getMediaId(),
title: props.media?.name,
year: props.media?.year,
type: props.media?.type, type: props.media?.type,
}, },
}) })
+11 -5
View File
@@ -54,12 +54,20 @@ const posterUrl = computed(() => {
return url return url
}) })
// 获得mediaid
function getMediaId() {
if (props.media?.tmdbid) return `tmdb:${props.media?.tmdbid}`
else if (props.media?.doubanid) return `douban:${props.media?.doubanid}`
}
// 查看媒体详情 // 查看媒体详情
async function viewMediaDetail() { async function viewMediaDetail() {
router.push({ router.push({
path: '/media', path: '/media',
query: { query: {
mediaid: `${props.media?.tmdbid ? `tmdb:${props.media?.tmdbid}` : `douban:${props.media?.doubanid}`}`, mediaid: getMediaId(),
title: props.media?.name,
year: props.media?.year,
type: props.media?.type, type: props.media?.type,
}, },
}) })
@@ -73,18 +81,16 @@ function showForkSubscribe() {
// 完成复用订阅 // 完成复用订阅
function finishForkSubscribe(subid: number) { function finishForkSubscribe(subid: number) {
subscribeId.value = subid subscribeId.value = subid
forkSubscribeDialog.value=false forkSubscribeDialog.value = false
subscribeEditDialog.value = true subscribeEditDialog.value = true
} }
// 删除订阅分享时处理 // 删除订阅分享时处理
function doDelete() { function doDelete() {
forkSubscribeDialog.value=false forkSubscribeDialog.value = false
// 通知父组件刷新 // 通知父组件刷新
emit('delete') emit('delete')
} }
</script> </script>
<template> <template>
@@ -87,12 +87,20 @@ const posterUrl = computed(() => {
return url return url
}) })
// 获得mediaid
function getMediaId() {
if (props.media?.tmdbid) return `tmdb:${props.media?.tmdbid}`
else if (props.media?.doubanid) return `douban:${props.media?.doubanid}`
}
// 查看媒体详情 // 查看媒体详情
async function viewMediaDetail() { async function viewMediaDetail() {
router.push({ router.push({
path: '/media', path: '/media',
query: { query: {
mediaid: `${props.media?.tmdbid ? `tmdb:${props.media?.tmdbid}` : `douban:${props.media?.doubanid}`}`, mediaid: getMediaId(),
title: props.media?.name,
year: props.media?.year,
type: props.media?.type, type: props.media?.type,
}, },
}) })
+7 -4
View File
@@ -9,13 +9,16 @@ const mediaid = route.query?.mediaid?.toString()
// 类型 // 类型
const type = route.query?.type?.toString() const type = route.query?.type?.toString()
// 标题
const title = route.query?.title?.toString()
// 年份
const year = route.query?.year?.toString()
</script> </script>
<template> <template>
<div> <div>
<MediaDetailView <MediaDetailView :mediaid="mediaid" :type="type" :title="title" :year="year" />
:mediaid="mediaid"
:type="type"
/>
</div> </div>
</template> </template>
+10 -2
View File
@@ -22,6 +22,12 @@ const type = route.query?.type?.toString() ?? ''
// 搜索字段 // 搜索字段
const area = route.query?.area?.toString() ?? '' const area = route.query?.area?.toString() ?? ''
// 搜索标题
const title = route.query?.title?.toString() ?? ''
// 搜索年份
const year = route.query?.year
// 搜索季 // 搜索季
const season = route.query?.season?.toString() ?? '' const season = route.query?.season?.toString() ?? ''
@@ -82,12 +88,14 @@ async function fetchData() {
} else { } else {
startLoadingProgress() startLoadingProgress()
let result: { [key: string]: any } let result: { [key: string]: any }
// 优先按TMDBID精确查询 // 如果keyword的格式是 xxxx:xxxxx 且:前面的xxxx为字符,则按照媒体ID格式搜索
if (keyword?.startsWith('tmdb:') || keyword?.startsWith('douban:') || keyword?.startsWith('bangumi:')) { if (/^[a-zA-Z]+:/.test(keyword)) {
result = await api.get(`search/media/${keyword}`, { result = await api.get(`search/media/${keyword}`, {
params: { params: {
mtype: type, mtype: type,
area, area,
title,
year,
season, season,
}, },
}) })
+6
View File
@@ -14,6 +14,8 @@ import { isNullOrEmptyObject } from '@/@core/utils'
// 输入参数 // 输入参数
const mediaProps = defineProps({ const mediaProps = defineProps({
mediaid: String, mediaid: String,
title: String,
year: String,
type: String, type: String,
}) })
@@ -68,6 +70,8 @@ async function getMediaDetail() {
if (mediaProps.mediaid && mediaProps.type) { if (mediaProps.mediaid && mediaProps.type) {
mediaDetail.value = await api.get(`media/${mediaProps.mediaid}`, { mediaDetail.value = await api.get(`media/${mediaProps.mediaid}`, {
params: { params: {
title: mediaProps.title,
year: mediaProps.year,
type_name: mediaProps.type, type_name: mediaProps.type,
}, },
}) })
@@ -402,6 +406,8 @@ function handleSearch(area: string) {
keyword, keyword,
type: mediaDetail.value.type, type: mediaDetail.value.type,
area, area,
title: mediaDetail.value.title,
year: mediaDetail.value.year,
season: mediaDetail.value.season, season: mediaDetail.value.season,
}, },
}) })