|
|
|
@ -1,5 +1,11 @@
|
|
|
|
|
import router from '../router';
|
|
|
|
|
import state from '../store/state';
|
|
|
|
|
import {
|
|
|
|
|
recommendPlaylist,
|
|
|
|
|
dailyRecommendPlaylist,
|
|
|
|
|
getPlaylistDetail,
|
|
|
|
|
} from '@/api/playlist';
|
|
|
|
|
import { isAccountLoggedIn } from '@/utils/auth';
|
|
|
|
|
|
|
|
|
|
export function hasListSource() {
|
|
|
|
|
return !state.player.isPersonalFM && state.player.playlistSource.id !== 0;
|
|
|
|
@ -20,3 +26,36 @@ export function getListSourcePath() {
|
|
|
|
|
return `/${state.player.playlistSource.type}/${state.player.playlistSource.id}`;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export async function getRecommendPlayList(limit, removePrivateRecommand) {
|
|
|
|
|
if (isAccountLoggedIn()) {
|
|
|
|
|
const playlists = await Promise.all([
|
|
|
|
|
dailyRecommendPlaylist(),
|
|
|
|
|
recommendPlaylist({ limit }),
|
|
|
|
|
]);
|
|
|
|
|
let recommend = playlists[0].recommend ?? [];
|
|
|
|
|
if (recommend.length) {
|
|
|
|
|
if (removePrivateRecommand) recommend = recommend.slice(1);
|
|
|
|
|
await replaceRecommendResult(recommend);
|
|
|
|
|
}
|
|
|
|
|
return recommend.concat(playlists[1].result).slice(0, limit);
|
|
|
|
|
} else {
|
|
|
|
|
const response = await recommendPlaylist({ limit });
|
|
|
|
|
return response.result;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function replaceRecommendResult(recommend) {
|
|
|
|
|
for (let r of recommend) {
|
|
|
|
|
if (specialPlaylist.indexOf(r.id) > -1) {
|
|
|
|
|
const data = await getPlaylistDetail(r.id, true);
|
|
|
|
|
const playlist = data.playlist;
|
|
|
|
|
if (playlist) {
|
|
|
|
|
r.name = playlist.name;
|
|
|
|
|
r.picUrl = playlist.coverImgUrl;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const specialPlaylist = [3136952023, 2829883282, 2829816518, 2829896389];
|
|
|
|
|