This commit is contained in:
qier222 2021-04-27 17:12:53 +08:00
parent fa9acc9c89
commit 1f02f6c71f
No known key found for this signature in database
GPG Key ID: 9C85007ED905F14D
2 changed files with 7 additions and 17 deletions

View File

@ -30,7 +30,6 @@
<script>
import { mapActions, mapMutations, mapState } from 'vuex';
import Modal from '@/components/Modal.vue';
import { userPlaylist } from '@/api/user';
import { addOrRemoveTrackFromPlaylist } from '@/api/playlist';
import { disableScrolling, enableScrolling } from '@/utils/ui';
@ -45,7 +44,7 @@ export default {
};
},
computed: {
...mapState(['modals', 'data']),
...mapState(['modals', 'data', 'liked']),
show: {
get() {
return this.modals.addTrackToPlaylistModal.show;
@ -64,31 +63,19 @@ export default {
},
},
ownPlaylists() {
return this.playlists.filter(
return this.liked.playlists.filter(
p =>
p.creator.userId === this.data.user.userId &&
p.id !== this.data.likedSongPlaylistID
);
},
},
created() {
this.getUserPlaylists();
},
methods: {
...mapMutations(['updateModal']),
...mapActions(['showToast']),
close() {
this.show = false;
},
getUserPlaylists() {
userPlaylist({
timestamp: new Date().getTime(),
limit: 1000,
uid: this.data.user.userId,
}).then(data => {
this.playlists = data.playlist;
});
},
addTrackToPlaylist(playlistID) {
addOrRemoveTrackFromPlaylist({
op: 'add',

View File

@ -30,7 +30,7 @@
<script>
import Modal from '@/components/Modal.vue';
import { mapMutations, mapState } from 'vuex';
import { mapMutations, mapState, mapActions } from 'vuex';
import { createPlaylist, addOrRemoveTrackFromPlaylist } from '@/api/playlist';
import { disableScrolling, enableScrolling } from '@/utils/ui';
@ -66,7 +66,8 @@ export default {
},
},
methods: {
...mapMutations(['updateModal']),
...mapMutations(['updateModal', 'updateData']),
...mapActions(['showToast', 'fetchLikedPlaylist']),
close() {
this.show = false;
this.title = '';
@ -94,6 +95,8 @@ export default {
}
this.close();
this.showToast('成功创建歌单');
this.updateData({ key: 'libraryPlaylistFilter', value: 'mine' });
this.fetchLikedPlaylist();
}
});
},