mirror of
https://github.com/koel/koel
synced 2024-12-29 22:13:06 +00:00
80 lines
2.3 KiB
Vue
80 lines
2.3 KiB
Vue
<template>
|
|
<section id="queueWrapper">
|
|
<ScreenHeader>
|
|
Current Queue
|
|
<ControlsToggler :showing-controls="showingControls" @toggleControls="toggleControls"/>
|
|
|
|
<template v-slot:meta>
|
|
<span v-if="meta.songCount" data-test="list-meta">
|
|
{{ pluralize(meta.songCount, 'song') }} • {{ meta.totalLength }}
|
|
</span>
|
|
</template>
|
|
|
|
<template v-slot:controls>
|
|
<SongListControls
|
|
v-if="songs.length && (!isPhone || showingControls)"
|
|
@playAll="playAll"
|
|
@playSelected="playSelected"
|
|
@clearQueue="clearQueue"
|
|
:songs="songs"
|
|
:config="songListControlConfig"
|
|
:selectedSongs="selectedSongs"
|
|
/>
|
|
</template>
|
|
</ScreenHeader>
|
|
|
|
<SongList
|
|
v-if="songs.length"
|
|
:items="songs"
|
|
:config="{ sortable: false }"
|
|
type="queue"
|
|
ref="songList"
|
|
/>
|
|
|
|
<ScreenPlaceholder v-else>
|
|
<template v-slot:icon>
|
|
<i class="fa fa-coffee"></i>
|
|
</template>
|
|
|
|
No songs queued.
|
|
<span class="secondary d-block" v-if="shouldShowShufflingAllLink">
|
|
How about
|
|
<a class="start" @click.prevent="shuffleAll">shuffling all songs</a>?
|
|
</span>
|
|
</ScreenPlaceholder>
|
|
</section>
|
|
</template>
|
|
|
|
<script lang="ts" setup>
|
|
import { computed, defineAsyncComponent, reactive, toRef } from 'vue'
|
|
import { pluralize } from '@/utils'
|
|
import { queueStore, songStore } from '@/stores'
|
|
import { playback } from '@/services'
|
|
import { useSongList } from '@/composables'
|
|
|
|
const ScreenHeader = defineAsyncComponent(() => import('@/components/ui/ScreenHeader.vue'))
|
|
const ScreenPlaceholder = defineAsyncComponent(() => import('@/components/ui/screen-placeholder.vue'))
|
|
|
|
const {
|
|
SongList,
|
|
SongListControls,
|
|
ControlsToggler,
|
|
songs,
|
|
songList,
|
|
meta,
|
|
selectedSongs,
|
|
showingControls,
|
|
songListControlConfig,
|
|
isPhone,
|
|
playSelected,
|
|
toggleControls
|
|
} = useSongList(toRef(queueStore.state, 'songs'), { clearQueue: true })
|
|
|
|
const songState = reactive(songStore.state)
|
|
|
|
const shouldShowShufflingAllLink = computed(() => songState.songs.length > 0)
|
|
|
|
const playAll = () => playback.queueAndPlay(songs.value.length ? songList.value.getAllSongsWithSort() : songStore.all)
|
|
const shuffleAll = async () => await playback.queueAndPlay(songStore.all, true)
|
|
const clearQueue = () => queueStore.clear()
|
|
</script>
|