重构 credits.vue 和 media.vue 组件,简化 API 路径处理,移除不必要的路由参数,同时优化 PersonCardListView 组件的样式。

This commit is contained in:
jxxghp
2025-05-26 21:28:52 +08:00
parent 8552203d43
commit 46c198be26
3 changed files with 18 additions and 20 deletions

View File

@@ -1,24 +1,28 @@
<script setup lang="ts">
import PersonCardListView from '@/views/discover/PersonCardListView.vue'
// 输入参数
const props = defineProps({
// API路径
paths: Array as PropType<string[]> | PropType<string>,
})
// 路由参数
const route = useRoute()
const id = route.query?.id?.toString()
const title = route.query?.title?.toString()
const source = route.query?.source?.toString()
const type = route.query?.type?.toString()
const apipath = route.query?.apipath?.toString()
// 标题
let title = route.query?.title?.toString()
// 计算API路径
function getApiPath(paths: string[] | string) {
if (Array.isArray(paths)) return paths.join('/')
else return paths
}
</script>
<template>
<div>
<VPageContentTitle :title="title" />
<PersonCardListView
:credits-id="id"
:credits-name="title"
:credits-source="source"
:credits-type="type"
:credits-apipath="apipath"
/>
<PersonCardListView :apipath="getApiPath(props.paths || '')" />
</div>
</template>

View File

@@ -14,12 +14,6 @@ const mediaid = route.query?.mediaid?.toString()
// 类型:电影、电视剧
const type = route.query?.type?.toString()
// 媒体信息来源TMDB、豆瓣
const source = route.query?.source?.toString() || 'themoviedb'
// TMDB ID
const page = route.query?.page?.toString() || '1'
// 标题
const title = route.query?.title?.toString()
@@ -29,6 +23,6 @@ const year = route.query?.year?.toString()
<template>
<div>
<MediaDetailView :mediaid="mediaid" :type="type" :source="source" :page="page" :title="title" :year="year" />
<MediaDetailView :mediaid="mediaid" :type="type" :title="title" :year="year" />
</div>
</template>