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

114 lines
4.5 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"/>
<AlbumArtOverlay :song="currentSong" v-if="preferences.showAlbumArtOverlay"/>
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'"/>
<YoutubeScreen v-if="sharedState.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, reactive, ref } from 'vue'
2022-04-15 14:24:30 +00:00
import { eventBus } from '@/utils'
import { preferenceStore, sharedStore } 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-15 17:00:08 +00:00
const UserListScreen = defineAsyncComponent(() => import('@/components/screens/user-list.vue'))
const AlbumArtOverlay = defineAsyncComponent(() => import('@/components/ui/album-art-overlay.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-15 17:00:08 +00:00
const YoutubeScreen = defineAsyncComponent(() => import('@/components/screens/youtube.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-15 17:00:08 +00:00
const preferences = reactive(preferenceStore.state)
const sharedState = reactive(sharedStore.state)
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>