mirror of
https://github.com/koel/koel
synced 2024-12-20 17:43:36 +00:00
36 lines
917 B
TypeScript
36 lines
917 B
TypeScript
import { merge } from 'lodash'
|
|
import { reactive } from 'vue'
|
|
|
|
import SongListControls from '@/components/song/SongListControls.vue'
|
|
|
|
export const useSongListControls = (
|
|
screen: ScreenName,
|
|
configOverrides: Partial<SongListControlsConfig> | (() => Partial<SongListControlsConfig>) = {}
|
|
) => {
|
|
const defaults: SongListControlsConfig = {
|
|
play: true,
|
|
addTo: {
|
|
queue: screen !== 'Queue',
|
|
favorites: screen !== 'Favorites',
|
|
},
|
|
clearQueue: screen === 'Queue',
|
|
deletePlaylist: screen === 'Playlist',
|
|
refresh: screen === 'Playlist',
|
|
filter: [
|
|
'Queue',
|
|
'Artist',
|
|
'Album',
|
|
'Favorites',
|
|
'RecentlyPlayed',
|
|
'Playlist',
|
|
'Search.Songs'
|
|
].includes(screen)
|
|
}
|
|
|
|
const config = merge(defaults, typeof configOverrides === 'function' ? configOverrides() : configOverrides)
|
|
|
|
return {
|
|
SongListControls,
|
|
config: reactive(config)
|
|
}
|
|
}
|