diff --git a/src/components/cards/TmdbSelectorCard.vue b/src/components/cards/TmdbSelectorCard.vue index 21a6bb5a..54130df9 100644 --- a/src/components/cards/TmdbSelectorCard.vue +++ b/src/components/cards/TmdbSelectorCard.vue @@ -2,10 +2,17 @@ import api from '@/api' import type { MediaInfo } from '@/api/types' +interface TmdbItem { + title: string + overview: string + tmdbid: number + poster: string +} + // update:modelValue 事件 const emit = defineEmits(['update:modelValue', 'close']) -const items = ref<{}[]>([]) +const items = ref([]) // 搜索词 const keyword = ref('') @@ -14,9 +21,9 @@ const keyword = ref('') const loading = ref(false) // 选中条目 -function selectMedia(item: MediaInfo) { +function selectMedia(item: TmdbItem) { console.log(item) - emit('update:modelValue', item.tmdb_id) + emit('update:modelValue', item.tmdbid) emit('close') } @@ -48,13 +55,11 @@ async function searchMedias() { // 赋值 for (const item of result) { - if (items.value.length > 0) - items.value.push({ type: 'divider', inset: true }) items.value.push({ - prependAvatar: getW500Image(item.poster_path), + tmdbid: item.tmdb_id || 0, + poster: getW500Image(item.poster_path), title: `${item.title}(${item.year})`, - subtitle: `${item.type} ${item.overview}`, - onClick: () => selectMedia(item), + overview: `${item.type} ${item.overview}`, }) } loading.value = false @@ -88,12 +93,35 @@ async function searchMedias() { -