added song.link share option, temporarily is its own entry in context menus
This commit is contained in:
parent
da2d057c02
commit
861d260b95
4 changed files with 231 additions and 88 deletions
|
@ -271,6 +271,25 @@ const app = new Vue({
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
songLinkShare(amUrl) {
|
||||||
|
notyf.open({type: "info", message: "Getting song.link share URL..."})
|
||||||
|
let self = this
|
||||||
|
httpRequest = new XMLHttpRequest();
|
||||||
|
httpRequest.open('GET', `https://api.song.link/v1-alpha.1/links?url=${amUrl}&userCountry=US`, true);
|
||||||
|
httpRequest.send();
|
||||||
|
httpRequest.onreadystatechange = function () {
|
||||||
|
if (httpRequest.readyState === 4) {
|
||||||
|
if (httpRequest.status === 200) {
|
||||||
|
let response = JSON.parse(httpRequest.responseText);
|
||||||
|
console.log(response);
|
||||||
|
self.copyToClipboard(response.pageUrl)
|
||||||
|
} else {
|
||||||
|
console.log('There was a problem with the request.');
|
||||||
|
notyf.error("There was a problem with the request.")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
mainMenuVisibility(val) {
|
mainMenuVisibility(val) {
|
||||||
if (val) {
|
if (val) {
|
||||||
(this.chrome.userinfo.id) ? this.chrome.menuOpened = !this.chrome.menuOpened : false
|
(this.chrome.userinfo.id) ? this.chrome.menuOpened = !this.chrome.menuOpened : false
|
||||||
|
@ -3364,6 +3383,15 @@ const app = new Vue({
|
||||||
app.copyToClipboard((u.data.data.length && u.data.data.length > 0) ? u.data.data[0].attributes.url : u.data.data.attributes.url)
|
app.copyToClipboard((u.data.data.length && u.data.data.length > 0) ? u.data.data[0].attributes.url : u.data.data.attributes.url)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"icon": "./assets/feather/share.svg",
|
||||||
|
"name": `${app.getLz('action.share')} (song.link)`,
|
||||||
|
"action": function () {
|
||||||
|
app.mkapi(app.mk.nowPlayingItem.attributes?.playParams?.kind ?? app.mk.nowPlayingItem.type ?? 'songs', false, app.mk.nowPlayingItem._songId ?? app.mk.nowPlayingItem.id ?? '').then(u => {
|
||||||
|
app.songLinkShare((u.data.data.length && u.data.data.length > 0) ? u.data.data[0].attributes.url : u.data.data.attributes.url)
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -410,7 +410,21 @@
|
||||||
app.mkapi(self.item.attributes.playParams.kind, false, self.item.relationships.catalog.data[0].id).then(u => { self.app.copyToClipboard((u.data.data.length && u.data.data.length > 0) ? u.data.data[0].attributes.url : u.data.data.attributes.url) })
|
app.mkapi(self.item.attributes.playParams.kind, false, self.item.relationships.catalog.data[0].id).then(u => { self.app.copyToClipboard((u.data.data.length && u.data.data.length > 0) ? u.data.data[0].attributes.url : u.data.data.attributes.url) })
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
self.app.copyToClipboard(self.item.attributes.url)}
|
self.app.copyToClipboard(self.item.attributes.url)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"icon": "./assets/feather/share.svg",
|
||||||
|
"name": `${app.getLz('action.share')} (song.link)`,
|
||||||
|
"action": function () {
|
||||||
|
if (!self.item.attributes.url && self.item.relationships) {
|
||||||
|
if (self.item.relationships.catalog) {
|
||||||
|
app.mkapi(self.item.attributes.playParams.kind, false, self.item.relationships.catalog.data[0].id).then(u => { self.app.songLinkShare((u.data.data.length && u.data.data.length > 0) ? u.data.data[0].attributes.url : u.data.data.attributes.url) })
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
self.app.songLinkShare(self.item.attributes.url)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
@ -561,7 +575,8 @@
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
app.playMediaItemById(item.attributes.playParams.id ?? item.id, item.attributes.playParams.kind ?? item.type, item.attributes.playParams.isLibrary ?? false, item.attributes.url)
|
app.playMediaItemById(item.attributes.playParams.id ?? item.id, item.attributes.playParams.kind ?? item.type, item.attributes.playParams.isLibrary ?? false, item.attributes.url)
|
||||||
}})
|
}
|
||||||
|
})
|
||||||
},
|
},
|
||||||
route() {
|
route() {
|
||||||
let kind = (this.item.attributes.playParams ? (this.item.attributes.playParams.kind ?? (this.item.type ?? '')) : (this.item.type ?? ''));
|
let kind = (this.item.attributes.playParams ? (this.item.attributes.playParams.kind ?? (this.item.type ?? '')) : (this.item.type ?? ''));
|
||||||
|
|
|
@ -402,6 +402,18 @@
|
||||||
}else {
|
}else {
|
||||||
self.app.copyToClipboard(self.item.attributes.url)}
|
self.app.copyToClipboard(self.item.attributes.url)}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"icon": "./assets/feather/share.svg",
|
||||||
|
"name": `${app.getLz('action.share')} (song.link)`,
|
||||||
|
"action": function () {
|
||||||
|
if (!self.item.attributes.url && self.item.relationships){
|
||||||
|
if (self.item.relationships.catalog){
|
||||||
|
app.mkapi(self.item.attributes.playParams.kind, false, self.item.relationships.catalog.data[0].id).then(u => {self.app.songLinkShare((u.data.data.length && u.data.data.length > 0)? u.data.data[0].attributes.url : u.data.data.attributes.url)})
|
||||||
|
}
|
||||||
|
}else {
|
||||||
|
self.app.songLinkShare(self.item.attributes.url)}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
88
src/renderer/views/components/share-sheet.ejs
Normal file
88
src/renderer/views/components/share-sheet.ejs
Normal file
|
@ -0,0 +1,88 @@
|
||||||
|
<script type="text/x-template" id="add-to-playlist">
|
||||||
|
<template>
|
||||||
|
<div class="modal-fullscreen addtoplaylist-panel" @click.self="app.resetState()" @contextmenu.self="app.resetState()">
|
||||||
|
<div class="modal-window">
|
||||||
|
<div class="modal-header">
|
||||||
|
<div class="modal-title">{{app.getLz('action.addToPlaylist')}}</div>
|
||||||
|
<button class="close-btn" @click="app.resetState()"></button>
|
||||||
|
</div>
|
||||||
|
<div class="modal-content">
|
||||||
|
<button class="playlist-item"
|
||||||
|
@click="app.addSelectedToNewPlaylist()" style="width:100%;">
|
||||||
|
<div class="icon"><%- include("../svg/plus.svg") %></div>
|
||||||
|
<div class="name">{{app.getLz('action.createPlaylist')}}</div>
|
||||||
|
</button>
|
||||||
|
<sidebar-playlist :playlist-select="playlistSelect" v-for="item in $root.getPlaylistFolderChildren('p.playlistsroot')" :item="item">
|
||||||
|
</sidebar-playlist>
|
||||||
|
</div>
|
||||||
|
<div class="modal-search">
|
||||||
|
<div class="search-input-container" style="width:100%;margin: 16px 0;">
|
||||||
|
<div class="search-input--icon"></div>
|
||||||
|
<input type="search"
|
||||||
|
ref="searchInput"
|
||||||
|
style="width:100%;"
|
||||||
|
spellcheck="false"
|
||||||
|
:placeholder="app.getLz('term.search') + '...'"
|
||||||
|
v-model="searchQuery"
|
||||||
|
@input="search()"
|
||||||
|
class="search-input">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
Vue.component('add-to-playlist', {
|
||||||
|
template: '#add-to-playlist',
|
||||||
|
data: function () {
|
||||||
|
return {
|
||||||
|
playlistSorted: [],
|
||||||
|
searchQuery: "",
|
||||||
|
focused: "",
|
||||||
|
app: this.$root,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
props: {
|
||||||
|
playlists: {
|
||||||
|
type: Array,
|
||||||
|
required: true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
mounted() {
|
||||||
|
this.search()
|
||||||
|
this.$refs.searchInput.focus()
|
||||||
|
this.$refs.searchInput.addEventListener('keydown', (e) => {
|
||||||
|
if (e.keyCode == 13) {
|
||||||
|
if (this.focused != "") {
|
||||||
|
this.addToPlaylist(this.focused)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
playlistSelect(playlist) {
|
||||||
|
if(playlist.type != "library-playlist-folders") {
|
||||||
|
this.addToPlaylist(playlist.id)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
addToPlaylist(id) {
|
||||||
|
app.addSelectedToPlaylist(id)
|
||||||
|
},
|
||||||
|
search() {
|
||||||
|
this.focused = ""
|
||||||
|
if (this.searchQuery == "") {
|
||||||
|
this.playlistSorted = this.playlists
|
||||||
|
} else {
|
||||||
|
this.playlistSorted = this.playlists.filter(playlist => {
|
||||||
|
return playlist.attributes.name.toLowerCase().indexOf(this.searchQuery.toLowerCase()) > -1
|
||||||
|
})
|
||||||
|
if (this.playlistSorted.length == 1) {
|
||||||
|
this.focused = this.playlistSorted[0].id
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script>
|
Loading…
Add table
Add a link
Reference in a new issue