feat: show like buttons to visitors

This commit is contained in:
qier222 2020-12-09 18:09:52 +08:00
parent fe1ae83b73
commit f68ae5c078
6 changed files with 34 additions and 42 deletions

View file

@ -37,7 +37,7 @@
</div>
</div>
<!-- 账号登录才会显示 like 图标 -->
<div class="like-button" v-show="accountLogin">
<div class="like-button">
<button-icon
@click.native="likeCurrentSong"
:title="$t('player.like')"
@ -189,9 +189,6 @@ export default {
let max = ~~(this.currentTrack.dt / 1000);
return max > 1 ? max - 1 : max;
},
accountLogin() {
return isAccountLoggedIn();
},
},
methods: {
...mapMutations([
@ -206,6 +203,7 @@ export default {
"previousTrack",
"playTrackOnListByID",
"addNextTrackEvent",
"showToast",
]),
play() {
if (this.playing) {
@ -269,6 +267,10 @@ export default {
return `${min}:${sec}`;
},
likeCurrentSong() {
if (!isAccountLoggedIn()) {
this.showToast("此操作需要登录网易云账号");
return;
}
let id = this.currentTrack.id;
let like = true;
if (this.liked.songs.includes(id)) like = false;