diff --git a/src/App.vue b/src/App.vue index 39ecdc2..609437c 100644 --- a/src/App.vue +++ b/src/App.vue @@ -19,10 +19,14 @@ /> + + + + diff --git a/src/components/ModalNewPlaylist.vue b/src/components/ModalNewPlaylist.vue new file mode 100644 index 0000000..2dbccaa --- /dev/null +++ b/src/components/ModalNewPlaylist.vue @@ -0,0 +1,144 @@ + + + + + diff --git a/src/components/TrackList.vue b/src/components/TrackList.vue index 49302df..1fcc25d 100644 --- a/src/components/TrackList.vue +++ b/src/components/TrackList.vue @@ -17,6 +17,13 @@
{{ $t("contextMenu.removeFromMyLikedSongs") }}
+
添加到歌单
+
从歌单中删除
{ + return []; // 'removeTrackFromPlaylist' + }, + }, }, data() { return { @@ -93,7 +107,7 @@ export default { }, }, methods: { - ...mapMutations(["updateLikedSongs"]), + ...mapMutations(["updateLikedSongs", "updateModal"]), ...mapActions(["nextTrack", "playTrackOnListByID", "showToast"]), openMenu(e, track) { if (!track.playable) { @@ -160,6 +174,39 @@ export default { } }); }, + addTrackToPlaylist() { + if (!isAccountLoggedIn()) { + this.showToast("此操作需要登录网易云账号"); + return; + } + this.updateModal({ + modalName: "addTrackToPlaylistModal", + key: "show", + value: true, + }); + this.updateModal({ + modalName: "addTrackToPlaylistModal", + key: "selectedTrackID", + value: this.rightClickedTrack.id, + }); + }, + removeTrackFromPlaylist() { + if (!isAccountLoggedIn()) { + this.showToast("此操作需要登录网易云账号"); + return; + } + let trackID = this.rightClickedTrack.id; + addOrRemoveTrackFromPlaylist({ + op: "del", + pid: this.id, + tracks: trackID, + }).then((data) => { + this.showToast( + data.body.code === 200 ? "已从歌单中删除" : data.body.message + ); + this.$parent.removeTrack(trackID); + }); + }, }, }; diff --git a/src/store/mutations.js b/src/store/mutations.js index 0c56d6a..a35e1c7 100644 --- a/src/store/mutations.js +++ b/src/store/mutations.js @@ -123,4 +123,7 @@ export default { updateToast(state, toast) { state.toast = toast; }, + updateModal(state, { modalName, key, value }) { + state.modals[modalName][key] = value; + }, }; diff --git a/src/store/state.js b/src/store/state.js index 00d1202..5dfd635 100644 --- a/src/store/state.js +++ b/src/store/state.js @@ -12,6 +12,16 @@ export default { text: "", timer: null, }, + modals: { + addTrackToPlaylistModal: { + show: false, + selectedTrackID: 0, + }, + newPlaylistModal: { + show: false, + afterCreateAddTrackID: 0, + }, + }, player: JSON.parse(localStorage.getItem("player")), settings: JSON.parse(localStorage.getItem("settings")), data: JSON.parse(localStorage.getItem("data")), diff --git a/src/views/library.vue b/src/views/library.vue index 3379de4..2afcf28 100644 --- a/src/views/library.vue +++ b/src/views/library.vue @@ -76,7 +76,7 @@ class="add-playlist" icon="plus" v-show="currentTab === 'playlists'" - @click="showAddPlaylistModal = true" + @click="openAddPlaylistModal" >新建歌单 @@ -109,39 +109,11 @@ - - - - -