mirror of
https://github.com/koel/koel
synced 2024-12-19 17:13:09 +00:00
35 lines
901 B
TypeScript
35 lines
901 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 = {
|
|
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)
|
|
}
|
|
}
|