Repository navigation
fix:修复歌手信息跳转更新失败和歌手头像丢失问题 - #632
Conversation
flystar233
commented
Dec 14, 2025
- 现在点击多个歌手名字时,歌手的头像和介绍都可以正常更新在页面了.
- 跳转到歌手弹窗可以正常显示头像了。
Summary of ChangesHello @flystar233, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! 此拉取请求主要旨在提升用户体验,通过修复在点击不同歌手时信息未能正确更新以及歌手头像显示异常的问题,确保了歌手详情页面的数据完整性和视觉一致性。 Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
本次 PR 修复了歌手信息更新和头像显示相关的两个 bug,代码改动方向正确。在 JumpArtist.vue 中,通过获取歌手详情来补充缺失的头像信息,解决了弹窗中头像丢失的问题。我对这部分逻辑提出了一个重构建议,以使其更加健壮,能够处理部分歌手有头像而部分没有的情况,并增加了错误日志记录。在 Artist/layout.vue 中,更新了路由守卫的判断逻辑,使用了 some 方法来检查路由,这比之前检查 matched[0] 的方式更可靠,能更好地处理嵌套路由的情况。总体来说,这是一个不错的修复,在采纳建议后代码质量会更高。
| // 检查是否有 cover 字段,如果没有则获取歌手详情 | ||
| const hasCover = props.artist.some((ar) => ar.cover); | ||
| if (hasCover) { | ||
| artistData.value = props.artist; | ||
| } else { | ||
| // 获取每个歌手的详情以获取头像 | ||
| const artistPromises = props.artist.map(async (ar) => { | ||
| try { | ||
| const result = await artistDetail(ar.id); | ||
| const artist = result.data?.artist; | ||
| return { | ||
| id: ar.id, | ||
| name: ar.name, | ||
| cover: artist?.cover || artist?.img1v1Url || artist?.picUrl, | ||
| }; | ||
| } catch { | ||
| return { id: ar.id, name: ar.name, cover: undefined }; | ||
| } | ||
| }); | ||
| artistData.value = await Promise.all(artistPromises); | ||
| } |
There was a problem hiding this comment.
当前的歌手封面检查逻辑不够健壮。使用 props.artist.some((ar) => ar.cover) 会在数组中至少有一个歌手已有封面时,跳过获取其他歌手的头像,这会导致部分歌手没有头像,UI 显示不一致。
一个更可靠的方法是单独处理每个歌手,只为缺少封面的歌手获取详情。这样可以确保所有歌手的数据在需要时都能被获取,同时避免了不必要的 API 调用。
此外,API 调用的 catch 块是空的。记录错误日志是一个好习惯,有助于调试。
建议进行如下重构,以解决上述两个问题:
// 检查是否有 cover 字段,如果没有则获取歌手详情
const artistPromises = props.artist.map(async (ar) => {
// 如果已有封面,则直接返回
if (ar.cover) {
return ar;
}
// 否则,获取歌手详情
try {
const result = await artistDetail(ar.id);
const artist = result.data?.artist;
return {
id: ar.id,
name: ar.name,
cover: artist?.cover || artist?.img1v1Url || artist?.picUrl,
};
} catch (error) {
console.error(`获取歌手 ${ar.name} (${ar.id}) 的详情失败:`, error);
return { id: ar.id, name: ar.name, cover: undefined };
}
});
artistData.value = await Promise.all(artistPromises);
|
update by gemini-code-assist |