feat: 在播放界面、评论区、专辑等页面添加具体评论数量#942
Conversation
Summary of ChangesHello @WorldSansha, 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! 此PR通过在播放界面和评论区集成评论数量显示,显著提升了用户体验。它引入了一个可配置的评论数量展示功能,允许用户一目了然地查看评论活动,无论是作为播放器控制上的紧凑型角标,还是评论面板内的完整计数,并提供了自定义其可见性和格式的选项。 Highlights
Changelog
Activity
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
|
|
/gemini review |
| // 获取专辑评论数量(专辑API不返回commentCount) | ||
| fetchAlbumCommentCount(id); |
| if (currentRequestId.value !== id) return; | ||
| setDetailData(formatCoverList(detail.album)[0]); | ||
| // 获取专辑评论数量(专辑API不返回commentCount) | ||
| fetchAlbumCommentCount(id); |
| const { timeDisplay, toggleTimeFormat } = useTimeFormat(); | ||
|
|
||
| // 格式化评论数量 | ||
| const formatCommentCount = computed(() => { |
There was a problem hiding this comment.
这部分计算可以提取到 src\utils\format.ts 工具函数中
然后在这里和歌单页面都能处理一下
There was a problem hiding this comment.
如果就专辑页面没有评论数量的话好像怪怪的(,而且其实也能从别的地方获取
|
/gemini review |
There was a problem hiding this comment.
Code Review
本次 PR 的主要目标是在多个界面(如播放器、评论区、专辑页)添加评论数量的显示,并提供了相关的设置选项。整体实现得很好,功能点覆盖全面,包括了 API 请求、状态管理、UI 展示和用户设置。
代码层面,我发现几处可以改进的地方:
- 在
PlayerControl.vue和album.vue中,获取评论数的异步请求里有空的catch块,建议加入console.error日志,以便于调试。 format.ts中的formatCommentCount函数逻辑可以简化,使其更具可读性。
除此之外,代码结构清晰,新功能的集成方式也比较合理。这些小调整将有助于提升代码的健壮性和可维护性。
| } catch { | ||
| // 忽略错误 | ||
| } |
| export const formatCommentCount = (count: number, mode: "full" | "compact" = "compact"): string | number => { | ||
| if (mode === "full") return count; | ||
| if (count >= 10000) { | ||
| const val = Math.floor(count / 1000) / 10; | ||
| return `${val % 1 === 0 ? val.toFixed(0) : val}W+`; | ||
| } | ||
| if (count >= 1000) { | ||
| const val = Math.floor(count / 100) / 10; | ||
| return `${val % 1 === 0 ? val.toFixed(0) : val}K+`; | ||
| } | ||
| return count; | ||
| }; |
There was a problem hiding this comment.
当前格式化评论数量的函数逻辑有些复杂,可以进行简化以提高可读性和可维护性。目前的实现使用了一些虽然巧妙但不太直观的数学运算来截断到一位小数。采用更直接的方法可以使代码意图更清晰。
| export const formatCommentCount = (count: number, mode: "full" | "compact" = "compact"): string | number => { | |
| if (mode === "full") return count; | |
| if (count >= 10000) { | |
| const val = Math.floor(count / 1000) / 10; | |
| return `${val % 1 === 0 ? val.toFixed(0) : val}W+`; | |
| } | |
| if (count >= 1000) { | |
| const val = Math.floor(count / 100) / 10; | |
| return `${val % 1 === 0 ? val.toFixed(0) : val}K+`; | |
| } | |
| return count; | |
| }; | |
| export const formatCommentCount = (count: number, mode: "full" | "compact" = "compact"): string | number => { | |
| if (mode === "full" || count < 1000) { | |
| return count; | |
| } | |
| if (count >= 10000) { | |
| const num = Math.floor((count / 10000) * 10) / 10; | |
| return `${num}W+`; | |
| } | |
| // count >= 1000 | |
| const num = Math.floor((count / 1000) * 10) / 10; | |
| return `${num}K+`; | |
| }; |
| } catch { | ||
| // 忽略错误 | ||
| } |
| * @param mode 显示模式("full" 显示完整数值,"compact" 缩减显示) | ||
| * @returns 格式化后的评论数量 | ||
| */ | ||
| export const formatCommentCount = (count: number, mode: "full" | "compact" = "compact"): string | number => { |
There was a problem hiding this comment.
不用传递 mode
可以直接在方法内使用 const settings = useSettingStore() 来获取
| // 格式化评论数量 | ||
| const formattedCommentCount = computed(() => { | ||
| const count = statusStore.songCommentCount; | ||
| const mode = settingStore.showCommentCount === "full" ? "full" : "compact"; |
There was a problem hiding this comment.
直接在方法内使用 settingStore,这里就没必要用 computed 了
移除 mode 参数,改为在函数内部通过 useSettingStore() 获取显示模式, 简化调用方并移除 PlayerControl 中不再需要的 computed 包装。 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
/gemini review |
概述
在全屏播放器的评论按钮右上角显示当前歌曲的评论数量角标,并在评论面板的"全部评论"标题旁显示具体评论数。
改动内容
评论面板
设置项
三种模式: