feat: show like buttons to visitors

master
qier222 4 years ago
parent fe1ae83b73
commit f68ae5c078

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

@ -11,18 +11,10 @@
<hr /> <hr />
<div class="item" @click="play">{{ $t("contextMenu.play") }}</div> <div class="item" @click="play">{{ $t("contextMenu.play") }}</div>
<div class="item" @click="playNext">{{ $t("contextMenu.playNext") }}</div> <div class="item" @click="playNext">{{ $t("contextMenu.playNext") }}</div>
<div <div class="item" @click="like" v-show="!isRightClickedTrackLiked">
class="item"
@click="like"
v-show="!isRightClickedTrackLiked && accountLogin"
>
{{ $t("contextMenu.saveToMyLikedSongs") }} {{ $t("contextMenu.saveToMyLikedSongs") }}
</div> </div>
<div <div class="item" @click="like" v-show="isRightClickedTrackLiked">
class="item"
@click="like"
v-show="isRightClickedTrackLiked && accountLogin"
>
{{ $t("contextMenu.removeFromMyLikedSongs") }} {{ $t("contextMenu.removeFromMyLikedSongs") }}
</div> </div>
</ContextMenu> </ContextMenu>
@ -99,9 +91,6 @@ export default {
isRightClickedTrackLiked() { isRightClickedTrackLiked() {
return this.liked.songs.includes(this.rightClickedTrack?.id); return this.liked.songs.includes(this.rightClickedTrack?.id);
}, },
accountLogin() {
return isAccountLoggedIn();
},
}, },
methods: { methods: {
...mapMutations(["updateLikedSongs"]), ...mapMutations(["updateLikedSongs"]),
@ -152,6 +141,10 @@ export default {
this.likeASong(this.rightClickedTrack.id); this.likeASong(this.rightClickedTrack.id);
}, },
likeASong(id) { likeASong(id) {
if (!isAccountLoggedIn()) {
this.showToast("此操作需要登录网易云账号");
return;
}
let like = true; let like = true;
let likedSongs = this.liked.songs; let likedSongs = this.liked.songs;
if (likedSongs.includes(id)) like = false; if (likedSongs.includes(id)) like = false;

@ -62,7 +62,7 @@
<div></div> <div></div>
</div> </div>
<div class="actions" v-if="!isTracklist"> <div class="actions" v-if="!isTracklist">
<button v-if="accountLogin" @click="likeThisSong"> <button @click="likeThisSong">
<svg-icon <svg-icon
icon-class="heart" icon-class="heart"
:style="{ :style="{
@ -80,8 +80,6 @@
</template> </template>
<script> <script>
import { isAccountLoggedIn } from "@/utils/auth";
import ArtistsInLine from "@/components/ArtistsInLine.vue"; import ArtistsInLine from "@/components/ArtistsInLine.vue";
import ExplicitSymbol from "@/components/ExplicitSymbol.vue"; import ExplicitSymbol from "@/components/ExplicitSymbol.vue";
import { mapState } from "vuex"; import { mapState } from "vuex";
@ -127,15 +125,12 @@ export default {
}, },
trackClass() { trackClass() {
let trackClass = [this.type]; let trackClass = [this.type];
if (!this.track.playable && this.settings.showUnavailableSongGrey) if (!this.track.playable && this.settings.showUnavailableSongInGreyStyle)
trackClass.push("disable"); trackClass.push("disable");
if (this.isPlaying) trackClass.push("playing"); if (this.isPlaying) trackClass.push("playing");
if (this.focus) trackClass.push("focus"); if (this.focus) trackClass.push("focus");
return trackClass; return trackClass;
}, },
accountLogin() {
return isAccountLoggedIn();
},
isMenuOpened() { isMenuOpened() {
return this.$parent.rightClickedTrack.id === this.track.id ? true : false; return this.$parent.rightClickedTrack.id === this.track.id ? true : false;
}, },

@ -44,7 +44,6 @@
{{ $t("common.play") }} {{ $t("common.play") }}
</ButtonTwoTone> </ButtonTwoTone>
<ButtonTwoTone <ButtonTwoTone
v-if="accountLogin"
:iconClass="dynamicDetail.isSub ? 'heart-solid' : 'heart'" :iconClass="dynamicDetail.isSub ? 'heart-solid' : 'heart'"
:iconButton="true" :iconButton="true"
:horizontalPadding="0" :horizontalPadding="0"
@ -161,9 +160,6 @@ export default {
this.tracks.map((t) => (time = time + t.dt)); this.tracks.map((t) => (time = time + t.dt));
return time; return time;
}, },
accountLogin() {
return isAccountLoggedIn();
},
filteredMoreAlbums() { filteredMoreAlbums() {
let moreAlbums = this.moreAlbums.filter((a) => a.id !== this.album.id); let moreAlbums = this.moreAlbums.filter((a) => a.id !== this.album.id);
let realAlbums = moreAlbums.filter((a) => a.type === "专辑"); let realAlbums = moreAlbums.filter((a) => a.type === "专辑");
@ -184,7 +180,7 @@ export default {
}, },
methods: { methods: {
...mapMutations(["appendTrackToPlayerList"]), ...mapMutations(["appendTrackToPlayerList"]),
...mapActions(["playFirstTrackOnList", "playTrackOnListByID"]), ...mapActions(["playFirstTrackOnList", "playTrackOnListByID", "showToast"]),
playAlbumByID(id, trackID = "first") { playAlbumByID(id, trackID = "first") {
if (this.tracks.find((t) => t.playable !== false) === undefined) { if (this.tracks.find((t) => t.playable !== false) === undefined) {
return; return;
@ -192,6 +188,10 @@ export default {
playAlbumByID(id, trackID); playAlbumByID(id, trackID);
}, },
likeAlbum() { likeAlbum() {
if (!isAccountLoggedIn()) {
this.showToast("此操作需要登录网易云账号");
return;
}
likeAAlbum({ likeAAlbum({
id: this.album.id, id: this.album.id,
t: this.dynamicDetail.isSub ? 0 : 1, t: this.dynamicDetail.isSub ? 0 : 1,

@ -11,7 +11,7 @@
}}</router-link> }}</router-link>
- -
{{ mv.data.name }} {{ mv.data.name }}
<div class="like-button" v-show="accountLogin"> <div class="like-button">
<button-icon @click.native="likeMV"> <button-icon @click.native="likeMV">
<svg-icon icon-class="heart-solid" v-if="mv.subed"></svg-icon> <svg-icon icon-class="heart-solid" v-if="mv.subed"></svg-icon>
<svg-icon icon-class="heart" v-else></svg-icon> <svg-icon icon-class="heart" v-else></svg-icon>
@ -40,6 +40,7 @@ import Plyr from "plyr";
import ButtonIcon from "@/components/ButtonIcon.vue"; import ButtonIcon from "@/components/ButtonIcon.vue";
import MvRow from "@/components/MvRow.vue"; import MvRow from "@/components/MvRow.vue";
import { mapActions } from "vuex";
export default { export default {
name: "mv", name: "mv",
@ -62,12 +63,8 @@ export default {
simiMvs: [], simiMvs: [],
}; };
}, },
computed: {
accountLogin() {
return isAccountLoggedIn();
},
},
methods: { methods: {
...mapActions(["showToast"]),
getData(id) { getData(id) {
mvDetail(id).then((data) => { mvDetail(id).then((data) => {
this.mv = data; this.mv = data;
@ -96,6 +93,10 @@ export default {
}); });
}, },
likeMV() { likeMV() {
if (!isAccountLoggedIn()) {
this.showToast("此操作需要登录网易云账号");
return;
}
likeAMV({ likeAMV({
mvid: this.mv.data.id, mvid: this.mv.data.id,
t: this.mv.subed ? 0 : 1, t: this.mv.subed ? 0 : 1,

@ -52,7 +52,7 @@
{{ $t("common.play") }} {{ $t("common.play") }}
</ButtonTwoTone> </ButtonTwoTone>
<ButtonTwoTone <ButtonTwoTone
v-if="accountLogin && playlist.creator.userId !== data.user.userId" v-if="playlist.creator.userId !== data.user.userId"
:iconClass="playlist.subscribed ? 'heart-solid' : 'heart'" :iconClass="playlist.subscribed ? 'heart-solid' : 'heart'"
:iconButton="true" :iconButton="true"
:horizontalPadding="0" :horizontalPadding="0"
@ -77,7 +77,7 @@
>{{ playlist.englishTitle }} · {{ playlist.updateFrequency }} >{{ playlist.englishTitle }} · {{ playlist.updateFrequency }}
</div> </div>
<div class="buttons" v-if="accountLogin"> <div class="buttons">
<ButtonTwoTone <ButtonTwoTone
class="play-button" class="play-button"
@click.native="playPlaylistByID()" @click.native="playPlaylistByID()"
@ -87,7 +87,7 @@
{{ $t("common.play") }} {{ $t("common.play") }}
</ButtonTwoTone> </ButtonTwoTone>
<ButtonTwoTone <ButtonTwoTone
v-if="accountLogin && playlist.creator.userId !== data.user.userId" v-if="playlist.creator.userId !== data.user.userId"
:iconClass="playlist.subscribed ? 'heart-solid' : 'heart'" :iconClass="playlist.subscribed ? 'heart-solid' : 'heart'"
:iconButton="true" :iconButton="true"
:horizontalPadding="0" :horizontalPadding="0"
@ -266,21 +266,22 @@ export default {
isLikeSongsPage() { isLikeSongsPage() {
return this.$route.name === "likedSongs"; return this.$route.name === "likedSongs";
}, },
accountLogin() {
return isAccountLoggedIn();
},
specialPlaylistInfo() { specialPlaylistInfo() {
return specialPlaylist[this.playlist.id]; return specialPlaylist[this.playlist.id];
}, },
}, },
methods: { methods: {
...mapMutations(["appendTrackToPlayerList"]), ...mapMutations(["appendTrackToPlayerList"]),
...mapActions(["playFirstTrackOnList", "playTrackOnListByID"]), ...mapActions(["playFirstTrackOnList", "playTrackOnListByID", "showToast"]),
playPlaylistByID(trackID = "first") { playPlaylistByID(trackID = "first") {
let trackIDs = this.playlist.trackIds.map((t) => t.id); let trackIDs = this.playlist.trackIds.map((t) => t.id);
playAList(trackIDs, this.playlist.id, "playlist", trackID); playAList(trackIDs, this.playlist.id, "playlist", trackID);
}, },
likePlaylist() { likePlaylist() {
if (!isAccountLoggedIn()) {
this.showToast("此操作需要登录网易云账号");
return;
}
subscribePlaylist({ subscribePlaylist({
id: this.playlist.id, id: this.playlist.id,
t: this.playlist.subscribed ? 2 : 1, t: this.playlist.subscribed ? 2 : 1,

Loading…
Cancel
Save