master
qier222 4 years ago
parent 3822b498a1
commit b2f758f0c4

@ -11,18 +11,14 @@
<Player <Player
v-if="this.$store.state.player.enabled" v-if="this.$store.state.player.enabled"
ref="player" ref="player"
v-show=" v-show="showPlayer"
['mv', 'loginUsername', 'login', 'loginAccount'].includes(
this.$route.name
) === false
"
/></transition> /></transition>
<Toast /> <Toast />
<ModalAddTrackToPlaylist v-if="isAccountLoggedIn" /> <ModalAddTrackToPlaylist v-if="isAccountLoggedIn" />
<ModalNewPlaylist v-if="isAccountLoggedIn" /> <ModalNewPlaylist v-if="isAccountLoggedIn" />
<transition name="slide-up"> <transition name="slide-up">
<Lyrics v-show="this.$store.state.showLyrics" /> </transition <Lyrics v-show="this.$store.state.showLyrics" />
>"> </transition>
</div> </div>
</template> </template>
@ -55,6 +51,13 @@ export default {
isAccountLoggedIn() { isAccountLoggedIn() {
return isAccountLoggedIn(); return isAccountLoggedIn();
}, },
showPlayer() {
return (
["mv", "loginUsername", "login", "loginAccount"].includes(
this.$route.name
) === false
);
},
}, },
created() { created() {
if (this.isElectron) { if (this.isElectron) {

@ -21,7 +21,7 @@
:src="currentTrack.al && currentTrack.al.picUrl | resizeImage(224)" :src="currentTrack.al && currentTrack.al.picUrl | resizeImage(224)"
@click="goToAlbum" @click="goToAlbum"
/> />
<div class="track-info"> <div class="track-info" :title="audioSource">
<div class="name" @click="goToList"> <div class="name" @click="goToList">
{{ currentTrack.name }} {{ currentTrack.name }}
</div> </div>
@ -155,8 +155,8 @@ export default {
}, },
mounted() { mounted() {
setInterval(() => { setInterval(() => {
this.progress = ~~this.player.seek(); this.progress = this.player.seek();
}, 500); }, 1000);
if (isAccountLoggedIn()) { if (isAccountLoggedIn()) {
userLikedSongsIDs(this.data.user.userId).then((data) => { userLikedSongsIDs(this.data.user.userId).then((data) => {
this.updateLikedSongs(data.ids); this.updateLikedSongs(data.ids);
@ -186,6 +186,11 @@ export default {
isCurrentTrackLiked() { isCurrentTrackLiked() {
return this.liked.songs.includes(this.currentTrack.id); return this.liked.songs.includes(this.currentTrack.id);
}, },
audioSource() {
return this.player._howler?._src.includes("kuwo.cn")
? "音源来自酷我音乐"
: "";
},
}, },
methods: { methods: {
...mapMutations(["updateLikedSongs", "toggleLyrics"]), ...mapMutations(["updateLikedSongs", "toggleLyrics"]),

@ -3,7 +3,7 @@
class="track" class="track"
:class="trackClass" :class="trackClass"
:style="trackStyle" :style="trackStyle"
:title="track.reason" :title="showUnavailableSongInGreyStyle ? track.reason : ''"
@mouseover="hover = true" @mouseover="hover = true"
@mouseleave="hover = false" @mouseleave="hover = false"
> >
@ -147,6 +147,9 @@ export default {
this.isMenuOpened this.isMenuOpened
); );
}, },
showUnavailableSongInGreyStyle() {
return this.$store.state.settings.showUnavailableSongInGreyStyle;
},
}, },
methods: { methods: {
goToAlbum() { goToAlbum() {

@ -122,6 +122,11 @@ const router = new VueRouter({
}, },
}); });
const originalPush = VueRouter.prototype.push;
VueRouter.prototype.push = function push(location) {
return originalPush.call(this, location).catch((err) => err);
};
router.beforeEach((to, from, next) => { router.beforeEach((to, from, next) => {
// 需要登录的逻辑 // 需要登录的逻辑
if (to.meta.requireLogin) { if (to.meta.requireLogin) {

@ -24,6 +24,7 @@ let localStorage = {
if (process.env.IS_ELECTRON === true) { if (process.env.IS_ELECTRON === true) {
localStorage.settings.automaticallyCacheSongs = true; localStorage.settings.automaticallyCacheSongs = true;
localStorage.settings.showUnavailableSongInGreyStyle = false;
} }
export default localStorage; export default localStorage;

@ -184,21 +184,18 @@ export default class {
_getAudioSourceFromUnblockMusic(track) { _getAudioSourceFromUnblockMusic(track) {
if (process.env.IS_ELECTRON !== true) return null; if (process.env.IS_ELECTRON !== true) return null;
const source = ipcRenderer.sendSync("unblock-music", track); const source = ipcRenderer.sendSync("unblock-music", track);
if (store.state.settings.automaticallyCacheSongs && source?.url) {
cacheTrack(track.id, source.url);
}
return source?.url; return source?.url;
} }
_getAudioSource(track) { _getAudioSource(track) {
return this._getAudioSourceFromCache(String(track.id)) return this._getAudioSourceFromCache(String(track.id))
.then((source) => { .then((source) => {
if (!source) return null; return source ?? this._getAudioSourceFromNetease(track);
return source;
})
.then((source) => {
if (source) return source;
return this._getAudioSourceFromNetease(track);
}) })
.then((source) => { .then((source) => {
if (source) return source; return source ?? this._getAudioSourceFromUnblockMusic(track);
return this._getAudioSourceFromUnblockMusic(track);
}); });
} }
_replaceCurrentTrack( _replaceCurrentTrack(
@ -216,6 +213,7 @@ export default class {
this._playAudioSource(source, autoplay); this._playAudioSource(source, autoplay);
return source; return source;
} else { } else {
store.dispatch("showToast", `无法播放 ${track.name}`);
ifUnplayableThen === "playNextTrack" ifUnplayableThen === "playNextTrack"
? this.playNextTrack() ? this.playNextTrack()
: this.playPrevTrack(); : this.playPrevTrack();

@ -22,16 +22,16 @@ export function isTrackPlayable(track) {
} }
} else if (track.fee === 4 || track.privilege?.fee === 4) { } else if (track.fee === 4 || track.privilege?.fee === 4) {
result.playable = false; result.playable = false;
result.reason = "Paid Album"; result.reason = "付费专辑";
} else if ( } else if (
track.noCopyrightRcmd !== null && track.noCopyrightRcmd !== null &&
track.noCopyrightRcmd !== undefined track.noCopyrightRcmd !== undefined
) { ) {
result.playable = false; result.playable = false;
result.reason = "No Copyright"; result.reason = "无版权";
} else if (track.privilege?.st < 0 && isAccountLoggedIn()) { } else if (track.privilege?.st < 0 && isAccountLoggedIn()) {
result.playable = false; result.playable = false;
result.reason = "The song has been removed from the shelves"; result.reason = "已下架";
} }
return result; return result;
} }

@ -1,39 +0,0 @@
import store from "@/store";
export function initMediaSession() {
if ("mediaSession" in navigator) {
navigator.mediaSession.setActionHandler("play", function () {
store.state.howler.play();
});
navigator.mediaSession.setActionHandler("pause", function () {
store.state.howler.pause();
});
navigator.mediaSession.setActionHandler("previoustrack", function () {
store.dispatch("previousTrack");
});
navigator.mediaSession.setActionHandler("nexttrack", function () {
store.dispatch("nextTrack");
});
navigator.mediaSession.setActionHandler("stop", () => {
store.state.howler.stop();
});
}
}
export function updateMediaSessionMetaData(track) {
if ("mediaSession" in navigator) {
let artists = track.ar.map((a) => a.name);
navigator.mediaSession.metadata = new window.MediaMetadata({
title: track.name,
artist: artists.join(","),
album: track.al.name,
artwork: [
{
src: track.al.picUrl + "?param=512y512",
type: "image/jpg",
sizes: "512x512",
},
],
});
}
}

@ -198,9 +198,6 @@ export default {
...mapMutations(["appendTrackToPlayerList"]), ...mapMutations(["appendTrackToPlayerList"]),
...mapActions(["playFirstTrackOnList", "playTrackOnListByID", "showToast"]), ...mapActions(["playFirstTrackOnList", "playTrackOnListByID", "showToast"]),
playAlbumByID(id, trackID = "first") { playAlbumByID(id, trackID = "first") {
if (this.tracks.find((t) => t.playable !== false) === undefined) {
return;
}
this.$store.state.player.playAlbumByID(id, trackID); this.$store.state.player.playAlbumByID(id, trackID);
}, },
likeAlbum(toast = false) { likeAlbum(toast = false) {

@ -106,9 +106,9 @@
<div class="section-title">相似歌手</div> <div class="section-title">相似歌手</div>
<CoverRow <CoverRow
type="artist" type="artist"
:columnNumber="7" :columnNumber="6"
gap="36px 28px" gap="36px 28px"
:items="similarArtists.slice(0, 14)" :items="similarArtists.slice(0, 12)"
/> />
</div> </div>
</div> </div>

@ -118,7 +118,7 @@ export default {
this.player = new Plyr(this.$refs.videoPlayer, videoOptions); this.player = new Plyr(this.$refs.videoPlayer, videoOptions);
this.player.volume = this.$store.state.player.volume; this.player.volume = this.$store.state.player.volume;
this.player.on("playing", () => { this.player.on("playing", () => {
this.$store.state.howler.pause(); this.$store.state.player.pause();
}); });
this.getData(this.$route.params.id); this.getData(this.$route.params.id);
console.log("网易云你这mv音频码率也太糊了吧🙄"); console.log("网易云你这mv音频码率也太糊了吧🙄");

Loading…
Cancel
Save