diff --git a/app/components/HomeMovieCard.vue b/app/components/HomeMovieCard.vue index d3ca2c1..d28da4a 100644 --- a/app/components/HomeMovieCard.vue +++ b/app/components/HomeMovieCard.vue @@ -16,6 +16,7 @@ const props = defineProps<{ lang?: string categories?: string[] countries?: string[] + sources?: { source: string, slug: string }[] } }>() @@ -23,9 +24,19 @@ const isPreviewVisible = ref(false) const previewStyle = ref>({}) let hideTimer: ReturnType | undefined +const movieSourcesQuery = computed(() => + (props.movie.sources || [{ source: props.movie.source, slug: props.movie.slug }]) + .filter((source) => source.source && source.slug) + .map((source) => `${source.source}:${source.slug}`) + .join(','), +) + const movieLink = computed(() => ({ path: `/phim/${props.movie.slug}`, - query: { source: props.movie.source }, + query: { + source: props.movie.source, + srcs: movieSourcesQuery.value || undefined, + }, })) function showPreview(event: MouseEvent) { @@ -75,8 +86,9 @@ onBeforeUnmount(() => {

{{ movie.name }}

{{ movie.episode || movie.year || movie.quality }}

- - {{ movie.source }} + + {{ movie.sources.length }} server diff --git a/app/pages/index.vue b/app/pages/index.vue index 1df6fcf..0e2dbdb 100644 --- a/app/pages/index.vue +++ b/app/pages/index.vue @@ -65,6 +65,23 @@ function uniqueHeroMovies(items: any[]) { return uniqueItems } +function movieSourcesQuery(movie: any) { + return (movie?.sources || [{ source: movie?.source, slug: movie?.slug }]) + .filter((source: any) => source.source && source.slug) + .map((source: any) => `${source.source}:${source.slug}`) + .join(',') +} + +function movieLink(movie: any) { + return { + path: `/phim/${movie?.slug}`, + query: { + source: movie?.source, + srcs: movieSourcesQuery(movie) || undefined, + }, + } +} + function selectHero(index: number) { heroIndex.value = index } @@ -102,6 +119,7 @@ watch(hero, async (currentHero) => { const detail = await $fetch(`/api/movies/${currentHero.slug}`, { query: { source: currentHero.source, + srcs: movieSourcesQuery(currentHero) || undefined, }, }) heroDetailCache.set(cacheKey, detail) @@ -283,7 +301,7 @@ useHead({ {{ heroDescription }}

- @@ -298,7 +316,7 @@ useHead({ aria-label="Thêm vào thư viện"> - @@ -344,7 +362,7 @@ useHead({
-