diff --git a/src/locale/lang/en.js b/src/locale/lang/en.js index 379e693..cdd5a45 100644 --- a/src/locale/lang/en.js +++ b/src/locale/lang/en.js @@ -51,6 +51,7 @@ export default { playlist: { playlist: "Playlists", updatedAt: "Updated at", + search: "Search in playlist", }, login: { accessToAll: "Access to all data", diff --git a/src/locale/lang/zh-CN.js b/src/locale/lang/zh-CN.js index 0d00f68..efd84ce 100644 --- a/src/locale/lang/zh-CN.js +++ b/src/locale/lang/zh-CN.js @@ -48,6 +48,7 @@ export default { playlist: { playlist: "歌单", updatedAt: "最后更新于", + search: "搜索歌单音乐", }, login: { accessToAll: "可访问全部数据", diff --git a/src/views/playlist.vue b/src/views/playlist.vue index 611cd5e..3aeb948 100644 --- a/src/views/playlist.vue +++ b/src/views/playlist.vue @@ -135,8 +135,22 @@ + + + song.name.toLowerCase().includes(this.playlistKeyword.toLowerCase()) || + song.al.name.toLowerCase().includes(this.playlistKeyword.toLowerCase()) || + song.ar.find(artist => artist.name.toLowerCase().includes(this.playlistKeyword.toLowerCase())) + ); + }, }, methods: { ...mapMutations(["appendTrackToPlayerList"]), @@ -374,6 +397,7 @@ export default { this.lastLoadedTrackIndex = data.playlist.tracks.length - 1; if (this.playlist.trackCount > this.tracks.length) { window.addEventListener("scroll", this.handleScroll, true); + window.addEventListener("input", this.handleSearch, this.playlistKeyword); } return data; }) @@ -384,11 +408,11 @@ export default { } }); }, - loadMore() { + loadMore(loadNum = 50) { let trackIDs = this.playlist.trackIds.filter((t, index) => { if ( index > this.lastLoadedTrackIndex && - index <= this.lastLoadedTrackIndex + 50 + index <= this.lastLoadedTrackIndex + loadNum ) return t; }); @@ -415,6 +439,15 @@ export default { this.loadMore(); } }, + handleSearch() { + if ( + this.lastLoadedTrackIndex + 1 === this.playlist.trackIds.length || + this.loadingMore + ) + return; + this.loadingMore = true; + this.loadMore(this.playlist.trackIds.length - this.lastLoadedTrackIndex); + }, openMenu(e) { this.$refs.playlistMenu.openMenu(e); }, @@ -452,7 +485,7 @@ export default {