Skip to content

✨ feat: 列表添加评论#621

Merged
imsyy merged 5 commits into
devfrom
dev-list
Dec 8, 2025
Merged

✨ feat: 列表添加评论#621
imsyy merged 5 commits into
devfrom
dev-list

Conversation

@imsyy
Copy link
Copy Markdown
Member

@imsyy imsyy commented Dec 8, 2025

No description provided.

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @imsyy, 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!

此拉取请求对列表相关的视图和功能进行了重大重构。它将通用的 UI 元素和逻辑提取到可重用的 Vue 组件(ListDetail、ListComment)和组合式函数(useListActions、useListDetail、useListScroll、useListSearch)中。这种模块化简化了专辑、我喜欢、歌单和播客视图,使其更易于维护和扩展。一个关键的新功能是将评论部分集成到这些列表视图中,允许用户在查看歌曲/项目及其相关评论之间切换。此外,还对桌面歌词功能进行了一些小改进,增强了用户交互和事件处理。

Highlights

  • 新组件: 引入了 "ListComment.vue" 和 "ListDetail.vue" 两个新组件,分别用于展示评论和列表详情。
  • 新组合式函数: 添加了 "useListActions.ts"、"useListDetail.ts"、"useListScroll.ts" 和 "useListSearch.ts",用于封装列表相关的通用逻辑。
  • 列表视图重构: 专辑、我喜欢、歌单和播客等列表视图被重构,以使用新的 "ListDetail" 组件和组合式函数,显著减少了代码重复并提高了可维护性。
  • 评论功能集成: "ListDetail" 组件现在包含一个 "showCommentTab" 属性,并且重构后的列表视图已更新,通过新的 "ListComment" 组件显示相关评论。
  • 桌面歌词改进: "DesktopLyric/index.vue" 中对事件监听器进行了小幅修改,以支持鼠标和触摸操作,并移除了菜单按钮的 "title" 属性,同时增加了 "handleMouseLeave" 函数。
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

这次的 PR 主要重构了列表页面的实现,引入了通用的 ListDetail 组件和一系列 composables,这使得代码更加模块化和可复用,非常棒!同时,为列表页添加了评论功能。

在审查代码时,我发现了一些可以优化的地方:

  1. ListComment 组件中,获取热门评论的函数在每次加载更多评论时都会被调用,这造成了不必要的网络请求。
  2. albumplaylistradio 页面中,onActivated 生命周期钩子中存在冗余的数据重置逻辑。

我已经就这些问题提出了具体的修改建议。总体来说,这是一次很棒的重构和功能添加!

commentHasMore.value = true;
}
// 获取热门评论
await getHotCommentData();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

getHotCommentData 函数在每次加载更多评论时都会被调用,这会产生不必要的网络请求。热门评论只需要在首次加载时获取一次即可。建议将此行代码移动到第 93 行的 if (clean) 代码块内部。

Comment thread src/views/List/album.vue
const isSame = detailData.value?.id === albumId.value;
// 专辑不同
if (!isSame) resetData(true);
getAlbumDetail(albumId.value, isSame);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

这里的 resetData(true) 调用是多余的。因为当 isSamefalse 时,传递给 getAlbumDetailrefresh 参数也为 false,而 getAlbumDetail 函数内部已经包含了重置数据的逻辑。移除此行可以简化代码并避免重复操作。

Comment thread src/views/List/playlist.vue Outdated
// 是否不相同
const isSame = oldPlaylistId.value === playlistId.value;
// 歌单不同
if (!isSame) resetPlaylistData(true);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

这里的 resetPlaylistData(true) 调用是多余的。因为当 isSamefalse 时,传递给 getPlaylistDetailrefresh 参数也为 false,而 getPlaylistDetail 函数内部已经包含了重置数据的逻辑。移除此行可以简化代码并避免重复操作。

Comment thread src/views/List/radio.vue Outdated
// 是否不相同
const isSame = oldRadioId.value === radioId.value;
// 播客不同,先立即清空数据,避免显示上一个播客
if (!isSame) resetData(true);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

这里的 resetData(true) 调用是多余的。getRadioDetail 函数内部已经同步调用了 setDetailData(null),并且通过 getRadioAllProgram 间接同步调用了 setListData([]),可以立即清空旧数据。移除此行可以简化代码。

@imsyy
Copy link
Copy Markdown
Member Author

imsyy commented Dec 8, 2025

/gemini review

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

这是一个很棒的重构 PR。它引入了 ListDetail 组件和几个可组合函数来处理列表页面的通用逻辑,这极大地清理了 album.vueliked.vueplaylist.vueradio.vue 中的代码。同时,它还为这些列表添加了查看评论的新功能。在 DesktopLyric/index.vue 中使用 PointerEvent 是对触摸支持的一个很好的改进。

我的审查主要集中在以下几个方面:

  • 新的 ListComment 组件中存在一些轻微的性能和代码重复问题。
  • ListDetail 中的一个类型安全改进。
  • DesktopLyric 中一个可访问性退步,按钮的 title 属性被移除了。

总的来说,这是一个高质量的 PR。

Comment on lines +93 to +99
if (clean) {
commentData.value = [];
commentPage.value = 1;
commentHasMore.value = true;
}
// 获取热门评论
await getHotCommentData();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

getHotCommentData 在每次调用 getCommentData 时都会被执行,包括在加载更多评论时。这会产生不必要的网络请求。热门评论通常只需要在初次加载时获取一次。建议将 await getHotCommentData() 移动到 if (clean) 代码块内部。

    if (clean) {
      commentData.value = [];
      commentPage.value = 1;
      commentHasMore.value = true;
      // 获取热门评论
      await getHotCommentData();
    }

Comment on lines +137 to +141
commentData.value = [];
commentHotData.value = null;
commentPage.value = 1;
commentHasMore.value = true;
getCommentData();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

watch 监听器中重置 commentDatacommentPagecommentHasMore 的逻辑与 getCommentData 函数中的逻辑重复了。getCommentDataclean=true (默认) 时已经处理了这些状态的重置。可以简化 watch 监听器以避免重复代码,并提高可维护性。

      commentHotData.value = null;
      getCommentData();

};

// 处理艺术家点击
const handleArtistClick = (artists: any) => {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

handleArtistClick 函数的 artists 参数类型为 any。为了更好的类型安全和代码可读性,建议为其指定明确的类型。根据上下文,SongType["artists"] 是一个合适的类型。

const handleArtistClick = (artists: SongType["artists"]) => {

<div class="header" align="center" justify="space-between">
<n-flex :wrap="false" align="center" justify="flex-start" size="small" @pointerdown.stop>
<div class="menu-btn" title="返回应用" @click.stop="sendToMain('win-show')">
<div class="menu-btn" @click.stop="sendToMain('win-show')">
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

这个按钮以及其他几个图标按钮的 title 属性被移除了。这些 title 属性在鼠标悬停时提供工具提示,对于仅有图标的按钮来说,这对用户体验和可访问性至关重要。建议将它们加回来,例如为这个按钮加上 title="返回应用"

          <div class="menu-btn" title="返回应用" @click.stop="sendToMain('win-show')">

@imsyy imsyy merged commit 0f0730d into dev Dec 8, 2025
3 checks passed
@imsyy imsyy deleted the dev-list branch December 10, 2025 14:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant