mirror of
https://github.com/koel/koel
synced 2024-12-29 22:13:06 +00:00
75 lines
2.3 KiB
Vue
75 lines
2.3 KiB
Vue
<template>
|
|
<article :class="mode" class="album-info" data-testid="album-info">
|
|
<h1 class="name">
|
|
<span>{{ album.name }}</span>
|
|
<button :title="`Play all songs in ${album.name}`" class="control play" type="button" @click.prevent="play">
|
|
<i class="fa fa-play"/>
|
|
</button>
|
|
</h1>
|
|
|
|
<main>
|
|
<AlbumThumbnail :entity="album"/>
|
|
|
|
<template v-if="info">
|
|
<div v-if="info.wiki?.summary" class="wiki">
|
|
<div v-if="showSummary" class="summary" v-html="info.wiki.summary"/>
|
|
<div v-if="showFull" class="full" v-html="info.wiki.full"/>
|
|
|
|
<button v-if="showSummary" class="more" data-testid="more-btn" @click.prevent="showingFullWiki = true">
|
|
Full Wiki
|
|
</button>
|
|
</div>
|
|
|
|
<TrackList v-if="info.tracks?.length" :album="album" :tracks="info.tracks" data-testid="album-info-tracks"/>
|
|
|
|
<footer>
|
|
Data ©
|
|
<a :href="info.url" rel="noopener" target="_blank">Last.fm</a>
|
|
</footer>
|
|
</template>
|
|
</main>
|
|
</article>
|
|
</template>
|
|
|
|
<script lang="ts" setup>
|
|
import { computed, defineAsyncComponent, ref, toRefs, watch } from 'vue'
|
|
import { useThirdPartyServices } from '@/composables'
|
|
import { songStore } from '@/stores'
|
|
import { playbackService } from '@/services'
|
|
import { mediaInfoService } from '@/services/mediaInfoService'
|
|
|
|
import AlbumThumbnail from '@/components/ui/AlbumArtistThumbnail.vue'
|
|
|
|
const TrackList = defineAsyncComponent(() => import('@/components/album/AlbumTrackList.vue'))
|
|
|
|
type DisplayMode = 'aside' | 'full'
|
|
|
|
const props = withDefaults(defineProps<{ album: Album, mode?: DisplayMode }>(), { mode: 'aside' })
|
|
const { album, mode } = toRefs(props)
|
|
|
|
const info = ref<AlbumInfo | null>(null)
|
|
const showingFullWiki = ref(false)
|
|
|
|
const { useLastfm } = useThirdPartyServices()
|
|
|
|
watch(album, async () => {
|
|
showingFullWiki.value = false
|
|
info.value = null
|
|
useLastfm.value && (info.value = await mediaInfoService.fetchForAlbum(album.value))
|
|
}, { immediate: true })
|
|
|
|
const showSummary = computed(() => mode.value !== 'full' && !showingFullWiki.value)
|
|
const showFull = computed(() => !showSummary.value)
|
|
|
|
const play = async () => playbackService.queueAndPlay(await songStore.fetchForAlbum(album.value))
|
|
</script>
|
|
|
|
<style lang="scss">
|
|
.album-info {
|
|
@include artist-album-info();
|
|
|
|
.track-listing {
|
|
margin-top: 2rem;
|
|
}
|
|
}
|
|
</style>
|