2022-04-15 14:24:30 +00:00
|
|
|
<template>
|
2024-04-04 22:20:42 +00:00
|
|
|
<article
|
2024-01-04 10:24:40 +00:00
|
|
|
:class="{ playing, external, selected: item.selected }"
|
2024-05-19 05:49:42 +00:00
|
|
|
class="song-item group text-k-text-secondary border-b border-k-border !max-w-full h-[64px] flex
|
2024-04-04 22:20:42 +00:00
|
|
|
items-center transition-[background-color,_box-shadow] ease-in-out duration-200
|
|
|
|
focus:rounded-md focus focus-within:rounded-md focus:ring-inset focus:ring-1 focus:!ring-k-accent
|
|
|
|
focus-within:ring-inset focus-within:ring-1 focus-within:!ring-k-accent
|
|
|
|
hover:bg-white/5 hover:ring-inset hover:ring-1 hover:ring-white/10 hover:rounded-md"
|
2022-05-10 12:09:31 +00:00
|
|
|
data-testid="song-item"
|
2022-07-15 15:23:12 +00:00
|
|
|
tabindex="0"
|
2022-11-12 21:38:31 +00:00
|
|
|
@dblclick.prevent.stop="play"
|
2022-05-10 12:09:31 +00:00
|
|
|
>
|
2022-11-12 21:38:31 +00:00
|
|
|
<span class="track-number">
|
2024-06-02 17:15:31 +00:00
|
|
|
<SoundBars v-if="playable.playback_state === 'Playing'" />
|
2024-05-19 05:49:42 +00:00
|
|
|
<span v-else class="text-k-text-secondary">
|
2024-06-02 17:15:31 +00:00
|
|
|
<template v-if="isSong(playable)">{{ playable.track || '' }}</template>
|
|
|
|
<Icon :icon="faPodcast" v-else />
|
2024-05-19 05:49:42 +00:00
|
|
|
</span>
|
2022-08-01 08:58:25 +00:00
|
|
|
</span>
|
2024-05-19 05:49:42 +00:00
|
|
|
<span class="thumbnail leading-none">
|
2024-06-02 17:15:31 +00:00
|
|
|
<SongThumbnail :playable="playable" />
|
2022-10-26 12:34:32 +00:00
|
|
|
</span>
|
2024-04-04 22:20:42 +00:00
|
|
|
<span class="title-artist flex flex-col gap-2 overflow-hidden">
|
|
|
|
<span class="title text-k-text-primary !flex gap-2 items-center">
|
|
|
|
<ExternalMark v-if="external" class="!inline-block" />
|
2024-06-02 17:15:31 +00:00
|
|
|
{{ playable.title }}
|
2024-01-04 10:24:40 +00:00
|
|
|
</span>
|
2024-05-19 05:49:42 +00:00
|
|
|
<span class="artist">{{ artist }}</span>
|
2022-11-12 21:38:31 +00:00
|
|
|
</span>
|
2024-05-19 05:49:42 +00:00
|
|
|
<span class="album">{{ album }}</span>
|
2024-01-18 11:13:05 +00:00
|
|
|
<template v-if="config.collaborative">
|
|
|
|
<span class="collaborator">
|
|
|
|
<UserAvatar :user="collaborator" width="24" />
|
|
|
|
</span>
|
2024-06-02 17:15:31 +00:00
|
|
|
<span :title="playable.collaboration.added_at" class="added-at">{{ playable.collaboration.fmt_added_at }}</span>
|
2024-01-18 11:13:05 +00:00
|
|
|
</template>
|
2022-11-12 21:38:31 +00:00
|
|
|
<span class="time">{{ fmtLength }}</span>
|
|
|
|
<span class="extra">
|
2024-06-02 17:15:31 +00:00
|
|
|
<LikeButton :playable="playable" />
|
2022-04-15 17:00:08 +00:00
|
|
|
</span>
|
2024-04-04 22:20:42 +00:00
|
|
|
</article>
|
2022-04-15 14:24:30 +00:00
|
|
|
</template>
|
|
|
|
|
2022-04-15 17:00:08 +00:00
|
|
|
<script lang="ts" setup>
|
2024-05-19 05:49:42 +00:00
|
|
|
import { faPodcast } from '@fortawesome/free-solid-svg-icons'
|
2022-07-05 18:01:33 +00:00
|
|
|
import { computed, toRefs } from 'vue'
|
2024-05-19 05:49:42 +00:00
|
|
|
import { getPlayableProp, isEpisode, isSong, requireInjection, secondsToHis } from '@/utils'
|
2024-01-18 11:13:05 +00:00
|
|
|
import { useAuthorization, useKoelPlus } from '@/composables'
|
2024-05-19 05:49:42 +00:00
|
|
|
import { PlayableListConfigKey } from '@/symbols'
|
2022-04-15 17:00:08 +00:00
|
|
|
|
2022-07-05 18:01:33 +00:00
|
|
|
import LikeButton from '@/components/song/SongLikeButton.vue'
|
2022-08-01 08:58:25 +00:00
|
|
|
import SoundBars from '@/components/ui/SoundBars.vue'
|
2022-10-26 12:34:32 +00:00
|
|
|
import SongThumbnail from '@/components/song/SongThumbnail.vue'
|
2024-01-18 11:13:05 +00:00
|
|
|
import UserAvatar from '@/components/user/UserAvatar.vue'
|
2024-04-04 22:20:42 +00:00
|
|
|
import ExternalMark from '@/components/ui/ExternalMark.vue'
|
2024-01-18 11:13:05 +00:00
|
|
|
|
2024-05-19 05:49:42 +00:00
|
|
|
const [config] = requireInjection<[Partial<PlayableListConfig>]>(PlayableListConfigKey, [{}])
|
2022-04-15 17:00:08 +00:00
|
|
|
|
2024-01-04 10:24:40 +00:00
|
|
|
const { currentUser } = useAuthorization()
|
2024-01-08 16:59:05 +00:00
|
|
|
const { isPlus } = useKoelPlus()
|
2024-01-04 10:24:40 +00:00
|
|
|
|
2024-05-19 05:49:42 +00:00
|
|
|
const props = defineProps<{ item: PlayableRow }>()
|
2022-11-12 21:38:31 +00:00
|
|
|
const { item } = toRefs(props)
|
2022-04-15 17:00:08 +00:00
|
|
|
|
2024-05-19 05:49:42 +00:00
|
|
|
const emit = defineEmits<{ (e: 'play', playable: Playable): void }>()
|
2024-03-25 22:59:38 +00:00
|
|
|
|
2024-06-02 17:15:31 +00:00
|
|
|
const playable = computed<Playable | CollaborativeSong>(() => item.value.playable)
|
|
|
|
const playing = computed(() => ['Playing', 'Paused'].includes(playable.value.playback_state!))
|
2024-05-19 05:49:42 +00:00
|
|
|
|
|
|
|
const external = computed(() => {
|
2024-06-02 17:15:31 +00:00
|
|
|
if (!isSong(playable.value)) return false
|
|
|
|
return isPlus.value && playable.value.owner_id !== currentUser.value?.id
|
2024-05-19 05:49:42 +00:00
|
|
|
})
|
|
|
|
|
2024-06-02 17:15:31 +00:00
|
|
|
const fmtLength = secondsToHis(playable.value.length)
|
|
|
|
const artist = computed(() => getPlayableProp(playable.value, 'artist_name', 'podcast_author'))
|
|
|
|
const album = computed(() => getPlayableProp(playable.value, 'album_name', 'podcast_title'))
|
2022-04-15 17:00:08 +00:00
|
|
|
|
2024-06-02 17:15:31 +00:00
|
|
|
const collaborator = computed<Pick<User, 'name' | 'avatar'>>(
|
|
|
|
() => (playable.value as CollaborativeSong).collaboration.user
|
|
|
|
)
|
2024-01-18 11:13:05 +00:00
|
|
|
|
2024-06-02 17:15:31 +00:00
|
|
|
const play = () => emit('play', playable.value)
|
2022-04-15 14:24:30 +00:00
|
|
|
</script>
|
|
|
|
|
2024-04-04 22:20:42 +00:00
|
|
|
<style lang="postcss" scoped>
|
|
|
|
article {
|
|
|
|
&.droppable {
|
|
|
|
@apply relative transition-none after:absolute after:w-full after:h-[3px] after:rounded after:bg-k-success after:top-0;
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2024-04-04 22:20:42 +00:00
|
|
|
&.dragover-bottom {
|
|
|
|
@apply after:top-auto after:bottom-0;
|
2022-10-26 12:34:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-04-15 14:24:30 +00:00
|
|
|
&.selected {
|
2024-04-04 22:20:42 +00:00
|
|
|
@apply bg-white/10;
|
2022-04-15 14:24:30 +00:00
|
|
|
}
|
|
|
|
|
2022-10-13 15:18:47 +00:00
|
|
|
&.playing {
|
2022-11-12 21:38:31 +00:00
|
|
|
.title, .track-number, .favorite {
|
2024-04-04 22:20:42 +00:00
|
|
|
@apply text-k-accent !important;
|
2022-10-13 15:18:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-11-12 21:38:31 +00:00
|
|
|
.title-artist {
|
|
|
|
span {
|
2024-04-04 22:20:42 +00:00
|
|
|
@apply overflow-hidden whitespace-nowrap text-ellipsis block;
|
2022-11-12 21:38:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-10-13 15:18:47 +00:00
|
|
|
button {
|
2024-04-04 22:20:42 +00:00
|
|
|
@apply text-current;
|
2022-04-15 14:24:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|