|
|
@ -1,5 +1,5 @@
|
|
|
|
<template>
|
|
|
|
<template>
|
|
|
|
<div class="search">
|
|
|
|
<div class="search" v-show="show">
|
|
|
|
<div class="row" v-show="artists.length > 0 || albums.length > 0">
|
|
|
|
<div class="row" v-show="artists.length > 0 || albums.length > 0">
|
|
|
|
<div class="artists">
|
|
|
|
<div class="artists">
|
|
|
|
<div class="section-title" v-show="artists.length > 0"
|
|
|
|
<div class="section-title" v-show="artists.length > 0"
|
|
|
@ -85,6 +85,7 @@
|
|
|
|
<script>
|
|
|
|
<script>
|
|
|
|
import { getTrackDetail } from "@/api/track";
|
|
|
|
import { getTrackDetail } from "@/api/track";
|
|
|
|
import { search } from "@/api/others";
|
|
|
|
import { search } from "@/api/others";
|
|
|
|
|
|
|
|
import NProgress from "nprogress";
|
|
|
|
|
|
|
|
|
|
|
|
import TrackList from "@/components/TrackList.vue";
|
|
|
|
import TrackList from "@/components/TrackList.vue";
|
|
|
|
import MvRow from "@/components/MvRow.vue";
|
|
|
|
import MvRow from "@/components/MvRow.vue";
|
|
|
@ -99,6 +100,7 @@ export default {
|
|
|
|
},
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
return {
|
|
|
|
|
|
|
|
show: false,
|
|
|
|
tracks: [],
|
|
|
|
tracks: [],
|
|
|
|
artists: [],
|
|
|
|
artists: [],
|
|
|
|
albums: [],
|
|
|
|
albums: [],
|
|
|
@ -108,7 +110,7 @@ export default {
|
|
|
|
},
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
computed: {
|
|
|
|
keywords() {
|
|
|
|
keywords() {
|
|
|
|
return this.$store.state.search.keywords;
|
|
|
|
return this.$route.params.keywords ?? "";
|
|
|
|
},
|
|
|
|
},
|
|
|
|
haveResult() {
|
|
|
|
haveResult() {
|
|
|
|
return (
|
|
|
|
return (
|
|
|
@ -135,20 +137,17 @@ export default {
|
|
|
|
artists: 100,
|
|
|
|
artists: 100,
|
|
|
|
playlists: 1000,
|
|
|
|
playlists: 1000,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
const keywords = this.keywords;
|
|
|
|
return search({
|
|
|
|
return search({ keywords, type: typeTable[type], limit: 16 }).then(
|
|
|
|
keywords: this.keywords,
|
|
|
|
(result) => {
|
|
|
|
type: typeTable[type],
|
|
|
|
|
|
|
|
limit: 16,
|
|
|
|
|
|
|
|
}).then((result) => {
|
|
|
|
return { result: result.result, type };
|
|
|
|
return { result: result.result, type };
|
|
|
|
}
|
|
|
|
});
|
|
|
|
);
|
|
|
|
|
|
|
|
},
|
|
|
|
},
|
|
|
|
getData() {
|
|
|
|
getData() {
|
|
|
|
const requests = [
|
|
|
|
NProgress.start();
|
|
|
|
this.search("artists"),
|
|
|
|
this.show = false;
|
|
|
|
this.search("albums"),
|
|
|
|
|
|
|
|
this.search("tracks"),
|
|
|
|
|
|
|
|
];
|
|
|
|
|
|
|
|
const requests2 = [this.search("musicVideos"), this.search("playlists")];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const requestAll = (requests) => {
|
|
|
|
const requestAll = (requests) => {
|
|
|
|
const keywords = this.keywords;
|
|
|
|
const keywords = this.keywords;
|
|
|
@ -156,6 +155,7 @@ export default {
|
|
|
|
if (keywords != this.keywords) return;
|
|
|
|
if (keywords != this.keywords) return;
|
|
|
|
results.map((result) => {
|
|
|
|
results.map((result) => {
|
|
|
|
const searchType = result.type;
|
|
|
|
const searchType = result.type;
|
|
|
|
|
|
|
|
if (result.result === undefined) return;
|
|
|
|
result = result.result;
|
|
|
|
result = result.result;
|
|
|
|
switch (searchType) {
|
|
|
|
switch (searchType) {
|
|
|
|
case "all":
|
|
|
|
case "all":
|
|
|
@ -179,9 +179,18 @@ export default {
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
NProgress.done();
|
|
|
|
|
|
|
|
this.show = true;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const requests = [
|
|
|
|
|
|
|
|
this.search("artists"),
|
|
|
|
|
|
|
|
this.search("albums"),
|
|
|
|
|
|
|
|
this.search("tracks"),
|
|
|
|
|
|
|
|
];
|
|
|
|
|
|
|
|
const requests2 = [this.search("musicVideos"), this.search("playlists")];
|
|
|
|
|
|
|
|
|
|
|
|
requestAll(requests);
|
|
|
|
requestAll(requests);
|
|
|
|
requestAll(requests2);
|
|
|
|
requestAll(requests2);
|
|
|
|
},
|
|
|
|
},
|
|
|
@ -194,19 +203,12 @@ export default {
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
created() {
|
|
|
|
created() {
|
|
|
|
if (this.keywords.length === 0) {
|
|
|
|
this.getData();
|
|
|
|
this.$store.commit("updateSearch", {
|
|
|
|
|
|
|
|
key: "keywords",
|
|
|
|
|
|
|
|
value: this.$route.params.keywords,
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
},
|
|
|
|
watch: {
|
|
|
|
watch: {
|
|
|
|
keywords: function () {
|
|
|
|
keywords: function (newKeywords) {
|
|
|
|
|
|
|
|
if (newKeywords.length === 0) return;
|
|
|
|
this.getData();
|
|
|
|
this.getData();
|
|
|
|
this.$router.replace({
|
|
|
|
|
|
|
|
params: { keywords: this.keywords },
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
};
|
|
|
|