A self-hosted media server and file management system
Vue ffmpegfile-serverjellyfinlaravelmediamedia-playermedia-servermediabrowsermediaservermusicmusic-librarymusic-playermusicplayerself-hostedvuejs
<script setup lang="ts">
import { useContinueWatching, useRecentlyAdded, useRecentlyReleased, useRecentlyUpdated, useRecentlyUploaded } from '@/service/explore/useExploreQueries';
import { getScreenSizeRank, toFormattedDate, toTimeSpan } from '@/service/util';
import { breakpointsTailwind, useBreakpoints } from '@vueuse/core';
import { interleaveSpotlightItems } from '@/service/explore/useSpotlightItems';
import { computed, onMounted } from 'vue';
import { useAppStore } from '@/stores/AppStore';
import LayoutBase from '@/layouts/LayoutBase.vue';
import RecentlyUploadedCard from '@/components/cards/data/RecentlyUploadedCard.vue';
import RecentlyWatchedCard from '@/components/cards/data/RecentlyWatchedCard.vue';
import ExploreRightSidebar from '@/components/panels/ExploreRightSidebar.vue';
import BrowseFolderCard from '@/components/cards/data/explore/BrowseFolderCard.vue';
import ExploreSpotlight from '@/components/explore/ExploreSpotlight.vue';
import ExploreShelf from '@/components/explore/ExploreShelf.vue';
const { data: recentlyUploadedMusic, isLoading: isLoadingRecentlyUploadedMusic } = useRecentlyUploaded('audio');
const { data: recentlyUploaded, isLoading: isLoadingRecentlyUploaded } = useRecentlyUploaded('video');
const { data: continueWatching, isLoading: isLoadingContinueWatching } = useContinueWatching();
const { data: recentlyReleased, isLoading: isLoadingRecentlyReleased } = useRecentlyReleased();
const { data: recentlyUpdated, isLoading: isLoadingRecentlyUpdated } = useRecentlyUpdated();
const { data: recentlyAdded, isLoading: isLoadingRecentlyAdded } = useRecentlyAdded();
const breakpoints = useBreakpoints({ ...breakpointsTailwind, '3xl': 2000 });
const gridFolderCount = computed(() => {
if (breakpoints.greaterOrEqual('3xl').value) return 8;
if (breakpoints.greaterOrEqual('2xl').value) return 6;
if (breakpoints.greaterOrEqual('sm').value) return 4;
return 3;
});
const spotlightItems = computed(() =>
interleaveSpotlightItems(
[
{ items: recentlyUpdated.value ?? [], label: 'Just Updated', dateField: 'updated_at' },
{ items: recentlyAdded.value ?? [], label: 'Just Added', dateField: 'created_at' },
{ items: recentlyReleased.value ?? [], label: 'Just Released', dateField: 'released_at' },
],
4,
),
);
const isLoadingSpotlight = computed(() => isLoadingRecentlyUpdated.value || isLoadingRecentlyAdded.value || isLoadingRecentlyReleased.value);
onMounted(() => {
if (getScreenSizeRank() >= 3) useAppStore().cycleSideBar('feed', 'list-card');
useAppStore().pageTitle = 'Explore';
});
</script>
<template>
<LayoutBase>
<template #content>
<div id="content-explore" class="page-height @container flex flex-col gap-8 text-sm">
<ExploreSpotlight v-if="spotlightItems.length || isLoadingSpotlight" :items="spotlightItems" :is-loading="isLoadingSpotlight" />
<ExploreShelf
v-if="isLoadingContinueWatching || !!continueWatching?.length"
title="Continue Watching"
skeleton-class="w-56 3xl:w-76 aspect-video"
:item-count="continueWatching?.length"
:is-loading="isLoadingContinueWatching"
>
<RecentlyWatchedCard class="3xl:w-76" v-for="(media, index) in continueWatching" :key="media.id" :media="media" :eagerLoad="index < 2" />
</ExploreShelf>
<ExploreShelf
title="Recently Updated"
skeleton-class="w-40 aspect-2-3"
:item-count="recentlyUpdated?.length"
:is-loading="isLoadingRecentlyUpdated"
:no-data-message="'Nothing released yet'"
>
<BrowseFolderCard v-for="(folder, index) in recentlyUpdated" :key="folder.id" :folder="folder" :eagerLoad="index < 2">
<span v-if="folder.series?.updated_at" class="text-foreground-1 truncate"> Updated {{ toTimeSpan(folder.series?.updated_at, '') }} </span>
</BrowseFolderCard>
</ExploreShelf>
<ExploreShelf
title="Recently Added"
skeleton-class="w-40 aspect-2-3"
:item-count="recentlyAdded?.length"
:is-loading="isLoadingRecentlyAdded"
:no-data-message="'Nothing added yet'"
:use-grid="true"
:class="'3xl:grid-cols-8 xs:grid-cols-3 grid grid-cols-2 sm:grid-cols-4 2xl:grid-cols-6'"
>
<BrowseFolderCard v-for="folder in recentlyAdded?.slice(0, gridFolderCount * 2)" :key="folder.id" :folder="folder" class="w-full">
<span v-if="folder.series?.created_at" class="text-foreground-1 truncate">
Added {{ toFormattedDate(folder.series?.created_at, false, { year: 'numeric', month: 'short', day: 'numeric' }) }}
</span>
</BrowseFolderCard>
</ExploreShelf>
<ExploreShelf
title="Recently Released"
skeleton-class="w-40 aspect-2-3"
:item-count="recentlyReleased?.length"
:is-loading="isLoadingRecentlyReleased"
:no-data-message="'Nothing released yet'"
>
<BrowseFolderCard v-for="folder in recentlyReleased" :key="folder.id" :folder="folder">
<span v-if="folder.series?.started_at" class="text-foreground-1 truncate">
{{ toFormattedDate(folder.series?.started_at, false, { year: 'numeric', month: 'long' }) }}
</span>
</BrowseFolderCard>
</ExploreShelf>
<ExploreShelf
v-if="isLoadingRecentlyUploaded || !!recentlyUploaded?.length"
title="Recently Uploaded Videos"
skeleton-class="w-56 3xl:w-76 aspect-video"
:item-count="recentlyUploaded?.length"
:is-loading="isLoadingRecentlyUploaded"
>
<RecentlyUploadedCard class="3xl:w-76" v-for="media in recentlyUploaded" :key="media.id" :media="media" />
</ExploreShelf>
<ExploreShelf
v-if="isLoadingRecentlyUploadedMusic || !!recentlyUploadedMusic?.length"
title="Recently Uploaded Music"
skeleton-class="w-40 aspect-square"
:item-count="recentlyUploadedMusic?.length"
:is-loading="isLoadingRecentlyUploadedMusic"
>
<RecentlyUploadedCard v-for="media in recentlyUploadedMusic" :key="media.id" :media="media" :force-audio="true" class="w-40" />
</ExploreShelf>
</div>
</template>
<template v-slot:sidebar>
<ExploreRightSidebar />
</template>
</LayoutBase>
</template>