koel/resources/assets/js/mixins/album-attributes.ts
2022-04-15 16:24:30 +02:00

14 lines
388 B
TypeScript

import { computed } from 'vue'
import { secondsToHis } from '@/utils'
export const useAlbumAttributes = () => {
const props = defineProps<{ album: Album }>()
const length = computed(() => props.album.songs.reduce((acc: number, song: Song) => acc + song.length, 0))
const fmtLength = computed(() => secondsToHis(length.value))
return {
props,
length,
fmtLength
}
}