adding search suggestions
This commit is contained in:
parent
6cbe9522fc
commit
167893e890
5 changed files with 152 additions and 18 deletions
|
@ -1903,8 +1903,18 @@ const app = new Vue({
|
|||
this.search.hints = [];
|
||||
return;
|
||||
}
|
||||
let hints = await (await app.mk.api.v3.music(`/v1/catalog/${app.mk.storefrontId}/search/hints?term=${this.search.term}`)).data.results;
|
||||
this.search.hints = hints ? hints.terms : [];
|
||||
let hints = await (await app.mk.api.v3.music(`/v1/catalog/${app.mk.storefrontId}/search/suggestions?term=${this.search.term}`,
|
||||
{"fields[albums]": "artwork,name,playParams,url,artistName,id",
|
||||
"fields[artists]": "url,name,artwork,id",
|
||||
"fields[songs]": "artwork,name,playParams,url,artistName,id",
|
||||
"kinds": "terms,topResults",
|
||||
"l": this.mklang,
|
||||
"limit[results:terms]": 5,
|
||||
"limit[results:topResults]": 5,
|
||||
"omit[resource]": "autos",
|
||||
"platform": "web",
|
||||
"types": "activities,albums,artists,editorial-items,music-movies,playlists,record-labels,songs,stations"})).data.results;
|
||||
this.search.hints = hints ? hints.suggestions : [];
|
||||
},
|
||||
getSongProgress() {
|
||||
if (this.playerLCD.userInteraction) {
|
||||
|
@ -3890,15 +3900,22 @@ const app = new Vue({
|
|||
if (e.keyCode == "40") {
|
||||
if (this.search.hints.length - 1 < this.search.cursor + 1) return;
|
||||
this.search.cursor++;
|
||||
this.search.term = this.search.hints[this.search.cursor];
|
||||
let item = this.search.hints[this.search.cursor]
|
||||
this.search.term = item.content ? (item.content?.attributes?.name ?? "") :item.displayTerm;
|
||||
} else if (e.keyCode == "38") {
|
||||
if (this.search.cursor == 0) return;
|
||||
this.search.cursor--;
|
||||
this.search.term = this.search.hints[this.search.cursor];
|
||||
let item = this.search.hints[this.search.cursor]
|
||||
this.search.term = item.content ? (item.content?.attributes?.name ?? "") :item.displayTerm;
|
||||
}
|
||||
},
|
||||
async searchQuery(term = this.search.term) {
|
||||
let self = this;
|
||||
if (typeof term === "object"){
|
||||
this.routeView(term)
|
||||
this.search.term = ""
|
||||
return;
|
||||
}
|
||||
if (term == "") {
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue