From e787555127c6f302395db5ea883bb98c7ad28fa8 Mon Sep 17 00:00:00 2001 From: Hawtim Zhang Date: Wed, 21 Oct 2020 15:45:42 +0800 Subject: [PATCH] fix: duplicate key warning in explore page (#29) * feat: add config to resolve path alias. * feat: use vue-i18n for language switch * feat: add .editorconfig for ide * fix: add no-referrer to avoid CROB * fix: setCookie and fix typo * feat: integrate vue-i18n * feat: player component i18n support * fix: duplicate key warning in explore page * fix: like songs number changed in library page --- src/views/explore.vue | 65 ++++++++++++++++++++++++++----------------- src/views/library.vue | 2 +- 2 files changed, 41 insertions(+), 26 deletions(-) diff --git a/src/views/explore.vue b/src/views/explore.vue index a331607..f1280a1 100644 --- a/src/views/explore.vue +++ b/src/views/explore.vue @@ -102,33 +102,48 @@ export default { getPlaylist() { this.loadingMore = true; if (this.activeCategory === "推荐歌单") { - recommendPlaylist({ limit: 100 }).then((data) => { - this.updatePlaylist(data.result); - }); - } else if (this.activeCategory === "精品歌单") { - let playlists = this.playlists; - let before = - playlists.length !== 0 - ? playlists[playlists.length - 1].updateTime - : 0; - highQualityPlaylist({ limit: 50, before }).then((data) => { - this.updatePlaylist(data.playlists); - this.hasMore = data.more; - }); - } else if (this.activeCategory === "排行榜") { - toplists().then((data) => { - this.updatePlaylist(data.list); - }); - } else { - topPlaylist({ - cat: this.activeCategory, - offset: this.playlists.length, - }).then((data) => { - this.updatePlaylist(data.playlists); - this.hasMore = data.more; - }); + return this.getRecommendPlayList() } + if (this.activeCategory === "精品歌单") { + return this.getHighQualityPlaylist() + } + if (this.activeCategory === "排行榜") { + return this.getTopLists() + } + return this.getTopPlayList() + }, + getRecommendPlayList() { + recommendPlaylist({ limit: 100 }).then(data => { + this.playlists = [] + this.updatePlaylist(data.result); + }); + }, + getHighQualityPlaylist() { + let playlists = this.playlists; + let before = + playlists.length !== 0 + ? playlists[playlists.length - 1].updateTime + : 0; + highQualityPlaylist({ limit: 50, before }).then((data) => { + this.updatePlaylist(data.playlists); + this.hasMore = data.more; + }); + }, + getTopLists() { + toplists().then((data) => { + this.playlists = [] + this.updatePlaylist(data.list); + }); }, + getTopPlayList() { + topPlaylist({ + cat: this.activeCategory, + offset: this.playlists.length, + }).then(data => { + this.updatePlaylist(data.playlists); + this.hasMore = data.more; + }); + } }, activated() { this.loadData(); diff --git a/src/views/library.vue b/src/views/library.vue index 2625189..7e52b74 100644 --- a/src/views/library.vue +++ b/src/views/library.vue @@ -149,7 +149,7 @@ export default { this.playlists.push(...data.playlist); } this.hasMorePlaylists = data.more; - this.likedSongsPlaylist = data.playlist[0]; + this.likedSongsPlaylist = this.playlists[0]; }); }, getLikedSongs(getLyric = true) {