Skip to content

Commit 481ba6b

Browse files
authored
fix: 相似歌手接口需要登录;未登录获取艺人热门歌曲没有图片 (#2286)
1 parent df82c7c commit 481ba6b

File tree

3 files changed

+21
-8
lines changed

3 files changed

+21
-8
lines changed

src/api/artist.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import request from '@/utils/request';
22
import { mapTrackPlayableStatus } from '@/utils/common';
3+
import { isAccountLoggedIn } from '@/utils/auth';
4+
import { getTrackDetail } from '@/api/track';
35

46
/**
57
* 获取歌手单曲
@@ -14,7 +16,13 @@ export function getArtist(id) {
1416
id,
1517
timestamp: new Date().getTime(),
1618
},
17-
}).then(data => {
19+
}).then(async data => {
20+
if (!isAccountLoggedIn()) {
21+
const trackIDs = data.hotSongs.map(t => t.id);
22+
const tracks = await getTrackDetail(trackIDs.join(','));
23+
data.hotSongs = tracks.songs;
24+
return data;
25+
}
1826
data.hotSongs = mapTrackPlayableStatus(data.hotSongs);
1927
return data;
2028
});

src/views/artist.vue

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -292,9 +292,11 @@ export default {
292292
this.mvs = data.mvs;
293293
this.hasMoreMV = data.hasMore;
294294
});
295-
similarArtists(id).then(data => {
296-
this.similarArtists = data.artists;
297-
});
295+
if (isAccountLoggedIn()) {
296+
similarArtists(id).then(data => {
297+
this.similarArtists = data.artists;
298+
});
299+
}
298300
},
299301
setPopularTracks(hotSongs) {
300302
const trackIDs = hotSongs.map(t => t.id);

src/views/explore.vue

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,13 @@ export default {
120120
setTimeout(() => {
121121
if (!this.show) NProgress.start();
122122
}, 1000);
123-
this.activeCategory =
124-
this.$route.query.category === undefined
125-
? '全部'
126-
: this.$route.query.category;
123+
const queryCategory = this.$route.query.category;
124+
if (queryCategory === undefined) {
125+
this.playlists = [];
126+
this.activeCategory = '全部';
127+
} else {
128+
this.activeCategory = queryCategory;
129+
}
127130
this.getPlaylist();
128131
},
129132
goToCategory(Category) {

0 commit comments

Comments
 (0)