File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -87,26 +87,26 @@ const getArtistData = async () => {
8787 }
8888 } else if (Array .isArray (props .artist )) {
8989 // 检查是否有 cover 字段,如果没有则获取歌手详情
90- const hasCover = props .artist .some ( (ar ) => ar . cover );
91- if ( hasCover ) {
92- artistData . value = props . artist ;
93- } else {
94- // 获取每个歌手的详情以获取头像
95- const artistPromises = props . artist . map ( async ( ar ) => {
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 {
105- return { id: ar .id , name: ar .name , cover: undefined } ;
106- }
107- });
108- artistData . value = await Promise . all ( artistPromises );
109- }
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 );
110110 }
111111};
112112
You can’t perform that action at this time.
0 commit comments