Skip to content

Commit

Permalink
fix: 相似歌手接口需要登录;未登录获取艺人热门歌曲没有图片 (qier222#2286)
Browse files Browse the repository at this point in the history
  • Loading branch information
Younglina authored Aug 13, 2024
1 parent df82c7c commit 481ba6b
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 8 deletions.
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 @@ -292,9 +292,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;
});
}
},
setPopularTracks(hotSongs) {
const trackIDs = hotSongs.map(t => t.id);
Expand Down
11 changes: 7 additions & 4 deletions src/views/explore.vue
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,13 @@ export default {
setTimeout(() => {
if (!this.show) NProgress.start();
}, 1000);
this.activeCategory =
this.$route.query.category === undefined
? '全部'
: this.$route.query.category;
const queryCategory = this.$route.query.category;
if (queryCategory === undefined) {
this.playlists = [];
this.activeCategory = '全部';
} else {
this.activeCategory = queryCategory;
}
this.getPlaylist();
},
goToCategory(Category) {
Expand Down

0 comments on commit 481ba6b

Please sign in to comment.