koel/resources/assets/js/components/layout/main-wrapper/MainContent.vue

87 lines
4.6 KiB
Vue
Raw Normal View History

2022-04-15 14:24:30 +00:00
<template>
2024-04-04 22:20:42 +00:00
<section
id="mainContent"
class="flex-1 relative overflow-hidden"
>
2022-04-15 14:24:30 +00:00
<!--
Most of the views are render-expensive and have their own UI states (viewport/scroll position), e.g. the song
lists), so we use v-show.
2022-04-15 17:00:08 +00:00
For those that don't need to maintain their own UI state, we use v-if and enjoy some code-splitting juice.
2022-04-15 14:24:30 +00:00
-->
2022-12-02 16:17:37 +00:00
<VisualizerScreen v-if="screen === 'Visualizer'" />
2024-05-19 05:49:42 +00:00
<AlbumArtOverlay v-if="showAlbumArtOverlay && currentSong && isSong(currentSong)" :album="currentSong?.album_id" />
2022-04-15 14:24:30 +00:00
2022-12-02 16:17:37 +00:00
<HomeScreen v-show="screen === 'Home'" />
<QueueScreen v-show="screen === 'Queue'" />
<AllSongsScreen v-show="screen === 'Songs'" />
<AlbumListScreen v-show="screen === 'Albums'" />
<ArtistListScreen v-show="screen === 'Artists'" />
<PlaylistScreen v-show="screen === 'Playlist'" />
<FavoritesScreen v-show="screen === 'Favorites'" />
<RecentlyPlayedScreen v-show="screen === 'RecentlyPlayed'" />
<UploadScreen v-show="screen === 'Upload'" />
<SearchExcerptsScreen v-show="screen === 'Search.Excerpt'" />
<GenreScreen v-show="screen === 'Genre'" />
2024-05-19 05:49:42 +00:00
<PodcastListScreen v-show="screen === 'Podcasts'" />
2022-04-15 14:24:30 +00:00
2022-12-02 16:17:37 +00:00
<GenreListScreen v-if="screen === 'Genres'" />
<SearchSongResultsScreen v-if="screen === 'Search.Songs'" />
<AlbumScreen v-if="screen === 'Album'" />
<ArtistScreen v-if="screen === 'Artist'" />
<SettingsScreen v-if="screen === 'Settings'" />
<ProfileScreen v-if="screen === 'Profile'" />
<PodcastScreen v-if="screen === 'Podcast'" />
2024-05-19 05:49:42 +00:00
<EpisodeScreen v-if="screen === 'Episode'" />
2022-12-02 16:17:37 +00:00
<UserListScreen v-if="screen === 'Users'" />
2024-05-19 05:49:42 +00:00
<YouTubeScreen v-if="useYouTube" v-show="screen === 'YouTube'" />
2022-12-02 16:17:37 +00:00
<NotFoundScreen v-if="screen === '404'" />
2022-04-15 14:24:30 +00:00
</section>
</template>
2022-04-15 17:00:08 +00:00
<script lang="ts" setup>
2022-09-21 08:40:06 +00:00
import { defineAsyncComponent, onMounted, ref, toRef } from 'vue'
2024-05-19 05:49:42 +00:00
import { isSong, requireInjection } from '@/utils'
import { preferenceStore } from '@/stores'
2022-11-18 18:44:20 +00:00
import { useRouter, useThirdPartyServices } from '@/composables'
2024-05-19 05:49:42 +00:00
import { CurrentPlayableKey } from '@/symbols'
2022-07-10 14:33:33 +00:00
2022-04-23 22:01:40 +00:00
import HomeScreen from '@/components/screens/HomeScreen.vue'
import QueueScreen from '@/components/screens/QueueScreen.vue'
2022-04-21 21:51:17 +00:00
import AlbumListScreen from '@/components/screens/AlbumListScreen.vue'
import ArtistListScreen from '@/components/screens/ArtistListScreen.vue'
2022-10-21 20:06:43 +00:00
import GenreListScreen from '@/components/screens/GenreListScreen.vue'
2022-04-21 16:06:45 +00:00
import AllSongsScreen from '@/components/screens/AllSongsScreen.vue'
import PlaylistScreen from '@/components/screens/PlaylistScreen.vue'
import FavoritesScreen from '@/components/screens/FavoritesScreen.vue'
2022-07-10 14:33:33 +00:00
import RecentlyPlayedScreen from '@/components/screens/RecentlyPlayedScreen.vue'
import UploadScreen from '@/components/screens/UploadScreen.vue'
import SearchExcerptsScreen from '@/components/screens/search/SearchExcerptsScreen.vue'
2024-05-19 05:49:42 +00:00
import PodcastListScreen from '@/components/screens/PodcastListScreen.vue'
2022-04-15 14:24:30 +00:00
2022-04-23 22:04:16 +00:00
const UserListScreen = defineAsyncComponent(() => import('@/components/screens/UserListScreen.vue'))
2022-04-23 22:47:21 +00:00
const AlbumArtOverlay = defineAsyncComponent(() => import('@/components/ui/AlbumArtOverlay.vue'))
const AlbumScreen = defineAsyncComponent(() => import('@/components/screens/AlbumScreen.vue'))
const ArtistScreen = defineAsyncComponent(() => import('@/components/screens/ArtistScreen.vue'))
2022-10-21 20:06:43 +00:00
const GenreScreen = defineAsyncComponent(() => import('@/components/screens/GenreScreen.vue'))
2024-05-19 05:49:42 +00:00
const PodcastScreen = defineAsyncComponent(() => import('@/components/screens/PodcastScreen.vue'))
const EpisodeScreen = defineAsyncComponent(() => import('@/components/screens/EpisodeScreen.vue'))
2022-04-21 22:20:21 +00:00
const SettingsScreen = defineAsyncComponent(() => import('@/components/screens/SettingsScreen.vue'))
2022-04-21 22:51:48 +00:00
const ProfileScreen = defineAsyncComponent(() => import('@/components/screens/ProfileScreen.vue'))
2024-05-19 05:49:42 +00:00
const YouTubeScreen = defineAsyncComponent(() => import('@/components/screens/YouTubeScreen.vue'))
2022-04-23 21:24:02 +00:00
const SearchSongResultsScreen = defineAsyncComponent(() => import('@/components/screens/search/SearchSongResultsScreen.vue'))
2022-09-28 04:28:00 +00:00
const NotFoundScreen = defineAsyncComponent(() => import('@/components/screens/NotFoundScreen.vue'))
2022-11-06 17:09:06 +00:00
const VisualizerScreen = defineAsyncComponent(() => import('@/components/screens/VisualizerScreen.vue'))
2022-04-15 14:24:30 +00:00
const { useYouTube } = useThirdPartyServices()
const { onRouteChanged, getCurrentScreen } = useRouter()
2022-10-13 15:18:47 +00:00
2024-05-19 05:49:42 +00:00
const currentSong = requireInjection(CurrentPlayableKey, ref(undefined))
const showAlbumArtOverlay = toRef(preferenceStore.state, 'show_album_art_overlay')
const screen = ref<ScreenName>('Home')
2022-04-15 14:24:30 +00:00
2022-11-18 18:44:20 +00:00
onRouteChanged(route => (screen.value = route.screen))
2022-04-15 14:24:30 +00:00
2024-04-04 22:20:42 +00:00
onMounted(() => (screen.value = getCurrentScreen()))
2022-04-15 14:24:30 +00:00
</script>