From 9b78ad3558ce20f24c3d14e259ef2ae36886ddcd Mon Sep 17 00:00:00 2001 From: 8790 <2467042336@qq.com> Date: Tue, 31 May 2022 07:30:41 +0800 Subject: [PATCH] feat: Added "Add to Playlist" on lyrics page --- src/views/lyrics.vue | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/src/views/lyrics.vue b/src/views/lyrics.vue index 2f5b7da1f7..27520d6146 100644 --- a/src/views/lyrics.vue +++ b/src/views/lyrics.vue @@ -87,6 +87,12 @@ " /> + + + @@ -229,7 +235,9 @@ import { lyricParser } from '@/utils/lyrics'; import ButtonIcon from '@/components/ButtonIcon.vue'; import * as Vibrant from 'node-vibrant/dist/vibrant.worker.min.js'; import Color from 'color'; +import { isAccountLoggedIn } from '@/utils/auth'; import { hasListSource, getListSourcePath } from '@/utils/playList'; +import locale from '@/locale'; export default { name: 'Lyrics', @@ -332,8 +340,25 @@ export default { clearInterval(this.lyricsInterval); }, methods: { - ...mapMutations(['toggleLyrics']), + ...mapMutations(['toggleLyrics', 'updateModal']), ...mapActions(['likeATrack']), + addToPlaylist() { + if (!isAccountLoggedIn()) { + this.showToast(locale.t('toast.needToLogin')); + return; + } + this.$store.dispatch('fetchLikedPlaylist'); + this.updateModal({ + modalName: 'addTrackToPlaylistModal', + key: 'show', + value: true, + }); + this.updateModal({ + modalName: 'addTrackToPlaylistModal', + key: 'selectedTrackID', + value: this.currentTrack?.id, + }); + }, playPrevTrack() { this.player.playPrevTrack(); },