Skip to content

相似歌手接口需要登录;未登录获取艺人热门歌曲没有图片 #2286

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Aug 13, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix: 相似歌手接口需要登录,导致无法进入艺人详情页面;未登录情况下艺人热门歌曲图片为空
  • Loading branch information
Younglina committed Aug 13, 2024
commit b8c63e2bc8bfd61c16c71892945b808c486037b1
10 changes: 9 additions & 1 deletion src/api/artist.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import request from '@/utils/request';
import { mapTrackPlayableStatus } from '@/utils/common';
import { isAccountLoggedIn } from '@/utils/auth';
import { getTrackDetail } from '@/api/track';

/**
* 获取歌手单曲
Expand All @@ -14,7 +16,13 @@ export function getArtist(id) {
id,
timestamp: new Date().getTime(),
},
}).then(data => {
}).then(async data => {
if (!isAccountLoggedIn()) {
const trackIDs = data.hotSongs.map(t => t.id);
const tracks = await getTrackDetail(trackIDs.join(','));
data.hotSongs = tracks.songs;
return data;
}
data.hotSongs = mapTrackPlayableStatus(data.hotSongs);
return data;
});
Expand Down
8 changes: 5 additions & 3 deletions src/views/artist.vue
Original file line number Diff line number Diff line change
Expand Up @@ -291,9 +291,11 @@ export default {
this.mvs = data.mvs;
this.hasMoreMV = data.hasMore;
});
similarArtists(id).then(data => {
this.similarArtists = data.artists;
});
if (isAccountLoggedIn()) {
similarArtists(id).then(data => {
this.similarArtists = data.artists;
});
}
},
goToAlbum(id) {
this.$router.push({
Expand Down