diff --git a/src/api/playlist.js b/src/api/playlist.js index b0e5994..cf6a236 100644 --- a/src/api/playlist.js +++ b/src/api/playlist.js @@ -183,3 +183,24 @@ export function addOrRemoveTrackFromPlaylist(params) { params, }); } + +/** + * 每日推荐歌曲 + * 说明 : 调用此接口 , 可获得每日推荐歌曲 ( 需要登录 ) + * @param {Object} params + * @param {string} params.op + * @param {string} params.pid + */ +export function dailyRecommendTracks() { + return request({ + url: "/recommend/songs", + method: "post", + params: { timestamp: new Date().getTime() }, + }).then((result) => { + result.data.dailySongs = mapTrackPlayableStatus( + result.data.dailySongs, + result.data.privileges + ); + return result; + }); +} diff --git a/src/components/DailyTracksCard.vue b/src/components/DailyTracksCard.vue new file mode 100644 index 0000000..043b7af --- /dev/null +++ b/src/components/DailyTracksCard.vue @@ -0,0 +1,145 @@ + + + + + diff --git a/src/components/Player.vue b/src/components/Player.vue index d2c7750..cbba0f5 100644 --- a/src/components/Player.vue +++ b/src/components/Player.vue @@ -290,9 +290,11 @@ export default { this.player.moveToFMTrash(); }, goToList() { - if (this.player.playlistSource.id === this.data.likedSongPlaylistID) + if (this.player.playlistSource.id === this.data.likedSongPlaylistID) { this.$router.push({ path: "/library/liked-songs" }); - else + } else if (this.player.playlistSource.type === "url") { + this.$router.push({ path: this.player.playlistSource.id }); + } else { this.$router.push({ path: "/" + @@ -300,6 +302,7 @@ export default { "/" + this.player.playlistSource.id, }); + } }, goToAlbum() { if (this.player.currentTrack.al.id === 0) return; diff --git a/src/components/TrackList.vue b/src/components/TrackList.vue index 0006a1b..c897a25 100644 --- a/src/components/TrackList.vue +++ b/src/components/TrackList.vue @@ -152,6 +152,14 @@ export default { "artist", trackID ); + } else if (this.dbclickTrackFunc === "dailyTracks") { + let trackIDs = this.tracks.map((t) => t.id); + this.$store.state.player.replacePlaylist( + trackIDs, + "/daily/songs", + "url", + trackID + ); } }, playThisListDefault(trackID) { diff --git a/src/router/index.js b/src/router/index.js index 1dab2f4..8e77e72 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -118,6 +118,11 @@ const routes = [ name: "settings", component: () => import("@/views/settings.vue"), }, + { + path: "/daily/songs", + name: "dailySongs", + component: () => import("@/views/dailyTracks.vue"), + }, ]; const router = new VueRouter({ routes, @@ -155,7 +160,7 @@ router.beforeEach((to, from, next) => { router.afterEach((to) => { if ( to.matched.some((record) => !record.meta.keepAlive) && - !["settings"].includes(to.name) + !["settings", "dailySongs"].includes(to.name) ) { NProgress.start(); } diff --git a/src/store/mutations.js b/src/store/mutations.js index b15650b..2d4ed38 100644 --- a/src/store/mutations.js +++ b/src/store/mutations.js @@ -42,4 +42,7 @@ export default { toggleLyrics(state) { state.showLyrics = !state.showLyrics; }, + updateDailyTracks(state, dailyTracks) { + state.dailyTracks = dailyTracks; + }, }; diff --git a/src/store/state.js b/src/store/state.js index 9f7065c..6dbccc2 100644 --- a/src/store/state.js +++ b/src/store/state.js @@ -34,6 +34,7 @@ export default { afterCreateAddTrackID: 0, }, }, + dailyTracks: [], player: JSON.parse(localStorage.getItem("player")), settings: JSON.parse(localStorage.getItem("settings")), data: JSON.parse(localStorage.getItem("data")), diff --git a/src/views/dailyTracks.vue b/src/views/dailyTracks.vue new file mode 100644 index 0000000..4a84f4a --- /dev/null +++ b/src/views/dailyTracks.vue @@ -0,0 +1,128 @@ + + + + + diff --git a/src/views/home.vue b/src/views/home.vue index c7b98cb..78912d9 100644 --- a/src/views/home.vue +++ b/src/views/home.vue @@ -25,8 +25,8 @@
For You
+ -
@@ -70,10 +70,11 @@ import NProgress from "nprogress"; import { mapState } from "vuex"; import CoverRow from "@/components/CoverRow.vue"; import FMCard from "@/components/FMCard.vue"; +import DailyTracksCard from "@/components/DailyTracksCard.vue"; export default { name: "Home", - components: { CoverRow, FMCard }, + components: { CoverRow, FMCard, DailyTracksCard }, data() { return { show: false,