koel/resources/assets/js/mixins/album-attributes.ts

15 lines
388 B
TypeScript
Raw Normal View History

2022-04-15 14:24:30 +00:00
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
}
}