mirror of
https://github.com/GiriNeko/YesPlayMusic.git
synced 2025-12-17 21:58:03 +00:00
fix: bugs
This commit is contained in:
parent
603e39f362
commit
2c8ba10e20
7 changed files with 59 additions and 80 deletions
|
|
@ -46,7 +46,7 @@
|
|||
<div class="like-button">
|
||||
<button-icon
|
||||
:title="$t('player.like')"
|
||||
@click.native="likeASong(player.currentTrack.id)"
|
||||
@click.native="likeATrack(player.currentTrack.id)"
|
||||
>
|
||||
<svg-icon
|
||||
v-show="!player.isCurrentTrackLiked"
|
||||
|
|
@ -203,7 +203,7 @@ export default {
|
|||
},
|
||||
methods: {
|
||||
...mapMutations(['toggleLyrics']),
|
||||
...mapActions(['showToast', 'likeASong']),
|
||||
...mapActions(['showToast', 'likeATrack']),
|
||||
goToNextTracksPage() {
|
||||
if (this.player.isPersonalFM) return;
|
||||
this.$route.name === 'next'
|
||||
|
|
|
|||
|
|
@ -12,10 +12,10 @@
|
|||
<div class="item" @click="play">{{ $t('contextMenu.play') }}</div>
|
||||
<div class="item" @click="playNext">{{ $t('contextMenu.playNext') }}</div>
|
||||
<hr />
|
||||
<div class="item" @click="like" v-show="!isRightClickedTrackLiked">
|
||||
<div v-show="!isRightClickedTrackLiked" class="item" @click="like">
|
||||
{{ $t('contextMenu.saveToMyLikedSongs') }}
|
||||
</div>
|
||||
<div class="item" @click="like" v-show="isRightClickedTrackLiked">
|
||||
<div v-show="isRightClickedTrackLiked" class="item" @click="like">
|
||||
{{ $t('contextMenu.removeFromMyLikedSongs') }}
|
||||
</div>
|
||||
<div
|
||||
|
|
@ -29,9 +29,9 @@
|
|||
<div :style="listStyles">
|
||||
<TrackListItem
|
||||
v-for="(track, index) in tracks"
|
||||
:track="track"
|
||||
:key="itemKey === 'id' ? track.id : `${track.id}${index}`"
|
||||
:highlightPlayingTrack="highlightPlayingTrack"
|
||||
:track="track"
|
||||
:highlight-playing-track="highlightPlayingTrack"
|
||||
@dblclick.native="playThisList(track.id)"
|
||||
@click.right.native="openMenu($event, track)"
|
||||
/>
|
||||
|
|
@ -41,7 +41,6 @@
|
|||
|
||||
<script>
|
||||
import { mapActions, mapMutations, mapState } from 'vuex';
|
||||
import { likeATrack } from '@/api/track';
|
||||
import { addOrRemoveTrackFromPlaylist } from '@/api/playlist';
|
||||
import { isAccountLoggedIn } from '@/utils/auth';
|
||||
|
||||
|
|
@ -102,6 +101,12 @@ export default {
|
|||
listStyles: {},
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
...mapState(['liked']),
|
||||
isRightClickedTrackLiked() {
|
||||
return this.liked.songs.includes(this.rightClickedTrack?.id);
|
||||
},
|
||||
},
|
||||
created() {
|
||||
if (this.type === 'tracklist') {
|
||||
this.listStyles = {
|
||||
|
|
@ -111,15 +116,9 @@ export default {
|
|||
};
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
...mapState(['liked']),
|
||||
isRightClickedTrackLiked() {
|
||||
return this.liked.songs.includes(this.rightClickedTrack?.id);
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
...mapMutations(['updateLikedSongs', 'updateModal']),
|
||||
...mapActions(['nextTrack', 'showToast']),
|
||||
...mapMutations(['updateModal']),
|
||||
...mapActions(['nextTrack', 'showToast', 'likeATrack']),
|
||||
openMenu(e, track) {
|
||||
this.rightClickedTrack = track;
|
||||
this.$refs.menu.openMenu(e);
|
||||
|
|
@ -184,27 +183,7 @@ export default {
|
|||
this.$store.state.player.addTrackToPlayNext(this.rightClickedTrack.id);
|
||||
},
|
||||
like() {
|
||||
this.likeASong(this.rightClickedTrack.id);
|
||||
},
|
||||
likeASong(id) {
|
||||
if (!isAccountLoggedIn()) {
|
||||
this.showToast('此操作需要登录网易云账号');
|
||||
return;
|
||||
}
|
||||
let like = true;
|
||||
let likedSongs = this.liked.songs;
|
||||
if (likedSongs.includes(id)) like = false;
|
||||
likeATrack({ id, like }).then(data => {
|
||||
if (data.code !== 200) return;
|
||||
if (like === false) {
|
||||
this.showToast(this.$t('toast.removedFromMyLikedSongs'));
|
||||
this.updateLikedSongs(likedSongs.filter(d => d !== id));
|
||||
} else {
|
||||
this.showToast(this.$t('toast.savedToMyLikedSongs'));
|
||||
likedSongs.push(id);
|
||||
this.updateLikedSongs(likedSongs);
|
||||
}
|
||||
});
|
||||
this.likeATrack(this.rightClickedTrack.id);
|
||||
},
|
||||
addTrackToPlaylist() {
|
||||
if (!isAccountLoggedIn()) {
|
||||
|
|
|
|||
|
|
@ -77,12 +77,12 @@
|
|||
</template>
|
||||
|
||||
<script>
|
||||
import ArtistsInLine from "@/components/ArtistsInLine.vue";
|
||||
import ExplicitSymbol from "@/components/ExplicitSymbol.vue";
|
||||
import { mapState } from "vuex";
|
||||
import ArtistsInLine from '@/components/ArtistsInLine.vue';
|
||||
import ExplicitSymbol from '@/components/ExplicitSymbol.vue';
|
||||
import { mapState } from 'vuex';
|
||||
|
||||
export default {
|
||||
name: "TrackListItem",
|
||||
name: 'TrackListItem',
|
||||
components: { ArtistsInLine, ExplicitSymbol },
|
||||
props: {
|
||||
track: Object,
|
||||
|
|
@ -95,13 +95,13 @@ export default {
|
|||
return { hover: false, trackStyle: {} };
|
||||
},
|
||||
computed: {
|
||||
...mapState(["settings"]),
|
||||
...mapState(['settings']),
|
||||
imgUrl() {
|
||||
let image =
|
||||
this.track?.al?.picUrl ??
|
||||
this.track?.album?.picUrl ??
|
||||
"https://p2.music.126.net/UeTuwE7pvjBpypWLudqukA==/3132508627578625.jpg";
|
||||
return image + "?param=224y224";
|
||||
'https://p2.music.126.net/UeTuwE7pvjBpypWLudqukA==/3132508627578625.jpg';
|
||||
return image + '?param=224y224';
|
||||
},
|
||||
artists() {
|
||||
if (this.track.ar !== undefined) return this.track.ar;
|
||||
|
|
@ -115,13 +115,13 @@ export default {
|
|||
return this.$parent.type;
|
||||
},
|
||||
isAlbum() {
|
||||
return this.type === "album";
|
||||
return this.type === 'album';
|
||||
},
|
||||
isTracklist() {
|
||||
return this.type === "tracklist";
|
||||
return this.type === 'tracklist';
|
||||
},
|
||||
isPlaylist() {
|
||||
return this.type === "playlist";
|
||||
return this.type === 'playlist';
|
||||
},
|
||||
isLiked() {
|
||||
return this.$parent.liked.songs.includes(this.track.id);
|
||||
|
|
@ -132,10 +132,10 @@ export default {
|
|||
trackClass() {
|
||||
let trackClass = [this.type];
|
||||
if (!this.track.playable && this.showUnavailableSongInGreyStyle)
|
||||
trackClass.push("disable");
|
||||
trackClass.push('disable');
|
||||
if (this.isPlaying && this.highlightPlayingTrack)
|
||||
trackClass.push("playing");
|
||||
if (this.focus) trackClass.push("focus");
|
||||
trackClass.push('playing');
|
||||
if (this.focus) trackClass.push('focus');
|
||||
return trackClass;
|
||||
},
|
||||
isMenuOpened() {
|
||||
|
|
@ -155,13 +155,13 @@ export default {
|
|||
},
|
||||
methods: {
|
||||
goToAlbum() {
|
||||
this.$router.push({ path: "/album/" + this.track.al.id });
|
||||
this.$router.push({ path: '/album/' + this.track.al.id });
|
||||
},
|
||||
playTrack() {
|
||||
this.$parent.playThisList(this.track.id);
|
||||
},
|
||||
likeThisSong() {
|
||||
this.$parent.likeASong(this.track.id);
|
||||
this.$parent.likeATrack(this.track.id);
|
||||
},
|
||||
},
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue