diff --git a/netease_api/routes/index.js b/netease_api/routes/index.js index 13e9112..e6af780 100644 --- a/netease_api/routes/index.js +++ b/netease_api/routes/index.js @@ -17,6 +17,7 @@ const table = { '/playlist/delete': require('../module/playlist_delete'), '/playlist/create': require('../module/playlist_create'), '/playlist/tracks': require('../module/playlist_tracks'), + '/playmode/intelligence/list': require('../module/playmode_intelligence_list'), '/recommend/songs': require('../module/recommend_songs'), '/login/qr/create': require('../module/login_qr_create'), '/login/qr/check': require('../module/login_qr_check'), diff --git a/src/api/playlist.js b/src/api/playlist.js index b1b9a84..58f6b98 100644 --- a/src/api/playlist.js +++ b/src/api/playlist.js @@ -206,3 +206,21 @@ export function dailyRecommendTracks() { return result; }); } + +/** + * 心动模式/智能播放 + * 说明 : 登录后调用此接口 , 可获取心动模式/智能播放列表 必选参数 : id : 歌曲 id + * - id : 歌曲 id + * - pid : 歌单 id + * - sid : 要开始播放的歌曲的 id (可选参数) + * @param {Object} params + * @param {number=} params.id + * @param {number=} params.pid + */ +export function intelligencePlaylist(params) { + return request({ + url: '/playmode/intelligence/list', + method: 'get', + params, + }); +} diff --git a/src/utils/Player.js b/src/utils/Player.js index 8fab401..0b09635 100644 --- a/src/utils/Player.js +++ b/src/utils/Player.js @@ -3,7 +3,7 @@ import shuffle from 'lodash/shuffle'; import { Howler, Howl } from 'howler'; import { cacheTrackSource, getTrackSource } from '@/utils/db'; import { getAlbum } from '@/api/album'; -import { getPlaylistDetail } from '@/api/playlist'; +import { getPlaylistDetail, intelligencePlaylist } from '@/api/playlist'; import { getArtist } from '@/api/artist'; import { personalFM, fmTrash } from '@/api/others'; import store from '@/store'; @@ -606,6 +606,18 @@ export default class { } this._replaceCurrentTrack(id); } + playIntelligenceListById(id, trackID = 'first', noCache = false) { + getPlaylistDetail(id, noCache).then(data => { + const randomId = Math.floor( + Math.random() * (data.playlist.trackIds.length + 1) + ); + const songId = data.playlist.trackIds[randomId].id; + intelligencePlaylist({ id: songId, pid: id }).then(result => { + let trackIDs = result.data.map(t => t.id); + this.replacePlaylist(trackIDs, id, 'playlist', trackID); + }); + }); + } addTrackToPlayNext(trackID, playNow = false) { this._playNextList.push(trackID); if (playNow) this.playNextTrack(); diff --git a/src/views/library.vue b/src/views/library.vue index 32acb7d..9b47a35 100644 --- a/src/views/library.vue +++ b/src/views/library.vue @@ -24,7 +24,7 @@ {{ liked.songs.length }} {{ $t('common.songs') }} - @@ -186,6 +186,14 @@ $t('contextMenu.likedPlaylists') }} + + +
{{ + $t('library.likedSongs') + }}
+
+
心动模式
+
@@ -318,6 +326,13 @@ export default { true ); }, + playIntelligenceList() { + this.$store.state.player.playIntelligenceListById( + this.liked.playlists[0].id, + 'first', + true + ); + }, updateCurrentTab(tab) { if (!isAccountLoggedIn() && tab !== 'playlists') { this.showToast(locale.t('toast.needToLogin')); @@ -358,6 +373,9 @@ export default { openPlaylistTabMenu(e) { this.$refs.playlistTabMenu.openMenu(e); }, + openPlayModeTabMenu(e) { + this.$refs.playModeTabMenu.openMenu(e); + }, changePlaylistFilter(type) { this.updateData({ key: 'libraryPlaylistFilter', value: type }); window.scrollTo({ top: 375, behavior: 'smooth' });