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

114 lines
4.6 KiB
Vue
Raw Normal View History

2022-04-15 14:24:30 +00:00
<template>
<section id="mainContent">
<!--
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-04-15 17:00:08 +00:00
<Visualizer v-if="showingVisualizer"/>
2022-04-25 13:07:38 +00:00
<AlbumArtOverlay v-if="showAlbumArtOverlay && currentSong" :album="currentSong?.album"/>
2022-04-15 14:24:30 +00:00
2022-04-15 17:00:08 +00:00
<HomeScreen v-show="view === 'Home'"/>
<QueueScreen v-show="view === 'Queue'"/>
<AllSongsScreen v-show="view === 'Songs'"/>
<AlbumListScreen v-show="view === 'Albums'"/>
<ArtistListScreen v-show="view === 'Artists'"/>
<PlaylistScreen v-show="view === 'Playlist'"/>
<FavoritesScreen v-show="view === 'Favorites'"/>
<RecentlyPlayedScreen v-show="view === 'RecentlyPlayed'"/>
<UploadScreen v-show="view === 'Upload'"/>
<SearchExcerptsScreen v-show="view === 'Search.Excerpt'"/>
2022-04-15 14:24:30 +00:00
2022-04-15 17:00:08 +00:00
<SearchSongResultsScreen v-if="view === 'Search.Songs'" :q="screenProps"/>
<AlbumScreen v-if="view === 'Album'" :album="screenProps"/>
<ArtistScreen v-if="view === 'Artist'" :artist="screenProps"/>
<SettingsScreen v-if="view === 'Settings'"/>
<ProfileScreen v-if="view === 'Profile'"/>
<UserListScreen v-if="view === 'Users'"/>
2022-04-25 13:07:38 +00:00
<YoutubeScreen v-if="useYouTube" v-show="view === 'YouTube'"/>
2022-04-15 14:24:30 +00:00
</section>
</template>
2022-04-15 17:00:08 +00:00
<script lang="ts" setup>
import { defineAsyncComponent, ref, toRef } from 'vue'
2022-04-15 14:24:30 +00:00
import { eventBus } from '@/utils'
import { commonStore, preferenceStore } from '@/stores'
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-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-04-15 14:24:30 +00:00
const RecentlyPlayedScreen = defineAsyncComponent(() => import('@/components/screens/RecentlyPlayedScreen.vue'))
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-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'))
2022-04-23 22:10:46 +00:00
const YoutubeScreen = defineAsyncComponent(() => import('@/components/screens/YouTubeScreen.vue'))
2022-04-21 18:39:18 +00:00
const UploadScreen = defineAsyncComponent(() => import('@/components/screens/UploadScreen.vue'))
2022-04-23 21:53:56 +00:00
const SearchExcerptsScreen = defineAsyncComponent(() => import('@/components/screens/search/SearchExcerptsScreen.vue'))
2022-04-23 21:24:02 +00:00
const SearchSongResultsScreen = defineAsyncComponent(() => import('@/components/screens/search/SearchSongResultsScreen.vue'))
2022-04-20 15:57:53 +00:00
const Visualizer = defineAsyncComponent(() => import('@/components/ui/Visualizer.vue'))
2022-04-15 14:24:30 +00:00
2022-04-25 13:07:38 +00:00
const showAlbumArtOverlay = toRef(preferenceStore.state, 'showAlbumArtOverlay')
const useYouTube = toRef(commonStore.state, 'useYouTube')
2022-04-15 17:00:08 +00:00
const showingVisualizer = ref(false)
const screenProps = ref<any>(null)
const view = ref<MainViewName>('Home')
const currentSong = ref<Song | null>(null)
2022-04-15 14:24:30 +00:00
2022-04-15 17:00:08 +00:00
eventBus.on({
LOAD_MAIN_CONTENT (_view: MainViewName, data: any) {
screenProps.value = data
view.value = _view
},
2022-04-15 14:24:30 +00:00
2022-04-15 17:00:08 +00:00
'TOGGLE_VISUALIZER': () => (showingVisualizer.value = !showingVisualizer.value),
'SONG_STARTED': (song: Song) => (currentSong.value = song)
2022-04-15 14:24:30 +00:00
})
</script>
<style lang="scss">
#mainContent {
flex: 1;
position: relative;
overflow: hidden;
> section {
position: absolute;
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
backface-visibility: hidden;
.main-scroll-wrap {
padding: 24px 24px 48px;
overflow: auto;
flex: 1;
-ms-overflow-style: -ms-autohiding-scrollbar;
place-content: start;
@media (hover: none) {
// Enable scroll with momentum on touch devices
overflow-y: scroll;
-webkit-overflow-scrolling: touch;
}
}
}
@media only screen and (max-width: 375px) {
> section {
// Leave some space for the "Back to top" button
.main-scroll-wrap {
padding-bottom: 64px;
}
}
}
}
</style>