2022-04-15 14:24:30 +00:00
|
|
|
<template>
|
|
|
|
<section id="albumsWrapper">
|
2022-04-15 17:00:08 +00:00
|
|
|
<ScreenHeader>
|
2022-04-15 14:24:30 +00:00
|
|
|
Albums
|
|
|
|
<template v-slot:controls>
|
2022-04-29 22:06:13 +00:00
|
|
|
<ViewModeSwitch v-model:mode="viewMode"/>
|
2022-04-15 14:24:30 +00:00
|
|
|
</template>
|
2022-04-15 17:00:08 +00:00
|
|
|
</ScreenHeader>
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-04-21 21:51:17 +00:00
|
|
|
<div ref="scroller" :class="`as-${viewMode}`" class="albums main-scroll-wrap" @scroll="scrolling">
|
|
|
|
<AlbumCard v-for="item in displayedItems" :key="item.id" :album="item" :layout="itemLayout"/>
|
2022-04-15 17:00:08 +00:00
|
|
|
<ToTopButton/>
|
2022-04-15 14:24:30 +00:00
|
|
|
</div>
|
|
|
|
</section>
|
|
|
|
</template>
|
|
|
|
|
2022-04-15 17:00:08 +00:00
|
|
|
<script lang="ts" setup>
|
2022-05-16 07:34:18 +00:00
|
|
|
import { computed, defineAsyncComponent, nextTick, ref, toRef, watch } from 'vue'
|
2022-04-15 17:00:08 +00:00
|
|
|
import { eventBus, limitBy } from '@/utils'
|
2022-04-15 14:24:30 +00:00
|
|
|
import { albumStore, preferenceStore as preferences } from '@/stores'
|
2022-04-15 17:00:08 +00:00
|
|
|
import { useInfiniteScroll } from '@/composables'
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-04-21 21:51:17 +00:00
|
|
|
const AlbumCard = defineAsyncComponent(() => import('@/components/album/AlbumCard.vue'))
|
2022-05-16 07:34:18 +00:00
|
|
|
const ScreenHeader = defineAsyncComponent(() => import('@/components/ui/ScreenHeader.vue'))
|
2022-04-24 08:29:14 +00:00
|
|
|
const ViewModeSwitch = defineAsyncComponent(() => import('@/components/ui/ViewModeSwitch.vue'))
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-04-15 17:00:08 +00:00
|
|
|
const viewMode = ref<ArtistAlbumViewMode>('thumbnails')
|
2022-05-16 07:34:18 +00:00
|
|
|
const albums = toRef(albumStore.state, 'albums')
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-04-15 17:00:08 +00:00
|
|
|
const {
|
|
|
|
ToTopButton,
|
|
|
|
displayedItemCount,
|
|
|
|
scroller,
|
|
|
|
scrolling,
|
|
|
|
makeScrollable
|
|
|
|
} = useInfiniteScroll(9)
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-04-15 17:00:08 +00:00
|
|
|
const displayedItems = computed(() => limitBy(albums.value, displayedItemCount.value))
|
|
|
|
const itemLayout = computed<ArtistAlbumCardLayout>(() => viewMode.value === 'thumbnails' ? 'full' : 'compact')
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-04-15 17:00:08 +00:00
|
|
|
watch(viewMode, () => preferences.albumsViewMode = viewMode.value)
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-04-15 17:00:08 +00:00
|
|
|
eventBus.on({
|
|
|
|
KOEL_READY () {
|
|
|
|
viewMode.value = preferences.albumsViewMode || 'thumbnails'
|
|
|
|
},
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-04-15 17:00:08 +00:00
|
|
|
async LOAD_MAIN_CONTENT (view: MainViewName) {
|
|
|
|
if (view === 'Albums') {
|
|
|
|
await nextTick()
|
|
|
|
makeScrollable(albums.value.length)
|
|
|
|
}
|
2022-04-15 14:24:30 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss">
|
|
|
|
#albumsWrapper {
|
|
|
|
.albums {
|
|
|
|
@include artist-album-wrapper();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|