File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2727<script setup lang="ts">
2828import type { SongType , MetaData } from " @/types/main" ;
2929import { useSettingStore } from " @/stores" ;
30- import { searchArtist } from " @/api/artist" ;
30+ import { searchArtist , artistDetail } from " @/api/artist" ;
3131import { uniq } from " lodash-es" ;
3232
3333const props = defineProps <{
@@ -86,7 +86,27 @@ const getArtistData = async () => {
8686 });
8787 }
8888 } else if (Array .isArray (props .artist )) {
89- artistData .value = props .artist ;
89+ // 检查是否有 cover 字段,如果没有则获取歌手详情
90+ const artistPromises = props .artist .map (async (ar ) => {
91+ // 如果已有封面,则直接返回
92+ if (ar .cover ) {
93+ return ar ;
94+ }
95+ // 否则,获取歌手详情
96+ try {
97+ const result = await artistDetail (ar .id );
98+ const artist = result .data ?.artist ;
99+ return {
100+ id: ar .id ,
101+ name: ar .name ,
102+ cover: artist ?.cover || artist ?.img1v1Url || artist ?.picUrl ,
103+ };
104+ } catch (error ) {
105+ console .error (` 获取歌手 ${ar .name } (${ar .id }) 的详情失败: ` , error );
106+ return { id: ar .id , name: ar .name , cover: undefined };
107+ }
108+ });
109+ artistData .value = await Promise .all (artistPromises );
90110 }
91111};
92112
Original file line number Diff line number Diff line change @@ -251,7 +251,9 @@ const listScroll = (e: Event) => {
251251
252252onBeforeRouteUpdate ((to ) => {
253253 listScrolling .value = false ;
254- if (to .matched [0 ].name !== " artist" ) return ;
254+ // 检查是否仍在 artist 路由下
255+ const isArtistRoute = to .matched .some ((m ) => m .name === " artist" );
256+ if (! isArtistRoute ) return ;
255257 artistType .value = to .name as string ;
256258 const id = Number (to .query .id as string );
257259 if (id && id !== artistId .value ) getArtistDetail (id );
You can’t perform that action at this time.
0 commit comments