paste songs into playlist
This commit is contained in:
parent
90dcde279a
commit
7670d0cac1
1 changed files with 36 additions and 0 deletions
|
@ -297,6 +297,13 @@
|
|||
beforeMount() {
|
||||
if( window.location.hash.includes("playlist") ) {
|
||||
window.addEventListener('keydown', this.getCopiedPlayListSongs);
|
||||
window.addEventListener('keydown', this.pasteSongs);
|
||||
}
|
||||
},
|
||||
beforeDestroy() {
|
||||
if( window.location.hash.includes("playlist") ) {
|
||||
window.removeEventListener('keydown', this.getCopiedPlayListSongs);
|
||||
window.removeEventListener('keydown', this.pasteSongs);
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
|
@ -771,6 +778,35 @@
|
|||
notyf.success(app.getLz('term.share.success'))
|
||||
}
|
||||
},
|
||||
async pasteSongs(event) {
|
||||
if( event.ctrlKey && event.keyCode === 86 ) {
|
||||
let clipboard = await navigator.clipboard.readText()
|
||||
let songs = []
|
||||
|
||||
clipboard = clipboard.split(",")
|
||||
clipboard.forEach(item => {
|
||||
songs.push({
|
||||
id: item.substring(item.indexOf("i=")+2, item.length),
|
||||
type: "songs",
|
||||
})
|
||||
})
|
||||
|
||||
this.app.mk.api.v3.music(`/v1/me/library/playlists/${this.data.id}/tracks`, {}, {
|
||||
fetchOptions: {
|
||||
method: "POST",
|
||||
body: JSON.stringify({
|
||||
data: songs
|
||||
})
|
||||
}
|
||||
}).then((response) => {
|
||||
songs.forEach(item => {
|
||||
this.app.mk.api.v3.music(`/v1/catalog/${app.mk.storefrontId}/songs/${item.id}`).then((response1) => {
|
||||
this.displayListing.push(response1.data.data[0])
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
},
|
||||
search() {
|
||||
let filtered = [];
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue