koel/resources/assets/js/components/artist/ArtistInfo.vue

48 lines
1.4 KiB
Vue
Raw Normal View History

2022-04-15 14:24:30 +00:00
<template>
2024-04-04 22:20:42 +00:00
<AlbumArtistInfo :mode="mode" data-testid="artist-info">
<template #header>{{ artist.name }}</template>
<template #art>
<ArtistThumbnail :entity="artist" />
</template>
<template v-if="info?.bio">
<ExpandableContentBlock v-if="mode === 'aside'">
<div v-html="info.bio.full" />
</ExpandableContentBlock>
<div v-else v-html="info.bio.full" />
</template>
<template v-if="info" #footer>
Data &copy;
<a :href="info.url" rel="openener" target="_blank">Last.fm</a>
</template>
</AlbumArtistInfo>
2022-04-15 14:24:30 +00:00
</template>
2022-04-15 17:00:08 +00:00
<script lang="ts" setup>
2024-04-04 22:20:42 +00:00
import { ref, toRefs, watch } from 'vue'
import { mediaInfoService } from '@/services'
import { useThirdPartyServices } from '@/composables'
2022-04-15 14:24:30 +00:00
2024-02-24 15:37:01 +00:00
import ArtistThumbnail from '@/components/ui/ArtistAlbumThumbnail.vue'
2024-04-04 22:20:42 +00:00
import AlbumArtistInfo from '@/components/ui/album-artist/AlbumOrArtistInfo.vue'
import ExpandableContentBlock from '@/components/ui/album-artist/ExpandableContentBlock.vue'
2022-04-15 14:24:30 +00:00
2022-07-10 09:31:55 +00:00
const props = withDefaults(defineProps<{ artist: Artist, mode?: MediaInfoDisplayMode }>(), { mode: 'aside' })
2022-04-15 17:00:08 +00:00
const { artist, mode } = toRefs(props)
2022-04-15 14:24:30 +00:00
const { useLastfm, useSpotify } = useThirdPartyServices()
2022-06-10 10:47:46 +00:00
const info = ref<ArtistInfo | null>(null)
watch(artist, async () => {
info.value = null
if (useLastfm.value || useSpotify.value) {
info.value = await mediaInfoService.fetchForArtist(artist.value)
}
}, { immediate: true })
2022-04-15 14:24:30 +00:00
</script>