koel/resources/assets/js/composables/useAlbumAttributes.ts
2022-04-19 21:26:06 +02:00

12 lines
335 B
TypeScript

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