Skip to content

✨ feat: 为评论区「抱一抱」功能添加开关和首次提示#976

Closed
WorldSansha wants to merge 2 commits intoimsyy:devfrom
WorldSansha:feature/hug-comment-toggle
Closed

✨ feat: 为评论区「抱一抱」功能添加开关和首次提示#976
WorldSansha wants to merge 2 commits intoimsyy:devfrom
WorldSansha:feature/hug-comment-toggle

Conversation

@WorldSansha
Copy link
Contributor

  • 在常规设置的其他设置中添加「评论区抱一抱」开关,默认开启
  • 首次双击评论时弹出确认提示,避免用户误触
  • 第二次取消时提供「取消且不再提示」选项,可直接关闭功能
  • 重新开启开关时自动重置提示状态
  • 限制抱一抱仅对歌曲评论生效,其他资源类型给出提示

- 在常规设置的其他设置中添加「评论区抱一抱」开关,默认开启
- 首次双击评论时弹出确认提示,避免用户误触
- 第二次取消时提供「取消且不再提示」选项,可直接关闭功能
- 重新开启开关时自动重置提示状态
- 限制抱一抱仅对歌曲评论生效,其他资源类型给出提示

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, 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

  • 评论区「抱一抱」功能开关: 在常规设置中新增了一个开关,用于启用或禁用评论区的「抱一抱」功能,默认开启。
  • 首次双击提示: 用户首次双击评论时,会弹出一个确认提示,以避免误触「抱一抱」功能。
  • 取消且不再提示选项: 在第二次取消「抱一抱」提示时,提供了「取消且不再提示」的选项,用户可以直接关闭该功能并停止后续提示。
  • 提示状态重置: 当用户重新开启「抱一抱」功能开关时,首次提示状态会自动重置,确保用户能再次收到提示。
  • 功能适用范围限制: 「抱一抱」功能现在仅对歌曲评论生效,对于其他资源类型的评论会给出相应的提示。
Changelog
  • src/components/List/CommentList.vue
    • 引入了 useSettingStore 以管理「抱一抱」功能的设置状态。
    • 重构了双击评论的处理逻辑,加入了首次提示、取消选项以及一个独立的 executeHug 函数。
    • 新增了逻辑以限制「抱一抱」功能仅对歌曲评论生效,并对其他资源类型显示警告信息。
  • src/components/Setting/config/general.ts
    • 在「其他设置」部分添加了一个新的开关配置项,用于控制「评论区抱一抱」功能的启用与禁用。
    • 实现了当「抱一抱」功能重新启用时,自动重置首次提示状态的逻辑。
  • src/stores/setting.ts
    • SettingState 接口中新增了 enableCommentHugshowedCommentHugTip 属性,用于存储「抱一抱」功能的启用状态和提示显示状态。
    • 在 Pinia store 的默认状态中,初始化了 enableCommentHugtrueshowedCommentHugTipfalse
Activity
  • 目前没有检测到任何评论、审查或进展活动。
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
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

This PR successfully introduces a 'hug' feature for comments, complete with a toggle switch and an initial usage prompt, demonstrating a thoughtful approach to user experience. A significant security concern has been identified: a potential Broken Access Control (IDOR) vulnerability, where the user's ID is passed as an API parameter, which could allow impersonation if the server trusts this parameter without sufficient validation. Furthermore, a check for 'UID login' mode is missing and should be added to align with other social features. On the code front, the hugTipDismissed state, currently a local component variable, should be moved to the Pinia store to ensure its persistence and provide a more consistent user experience across page navigations, including proper initialization and resetting when the feature is re-enabled.

Comment on lines 169 to +188
const handleDoubleClick = debounce(async (item: CommentType) => {
if (!settingStore.enableCommentHug) return;
// 首次双击提示
if (!settingStore.showedCommentHugTip) {
window.$dialog.warning({
title: "抱一抱",
content: "双击评论会向评论者发送「抱一抱」,是否继续?",
positiveText: "继续",
negativeText: hugTipDismissed ? "取消且不再提示" : "取消",
onPositiveClick: () => {
settingStore.showedCommentHugTip = true;
executeHug(item);
},
onNegativeClick: () => {
if (hugTipDismissed) {
settingStore.showedCommentHugTip = true;
settingStore.enableCommentHug = false;
}
hugTipDismissed = true;
},
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

为了实现状态持久化,这里应使用 store 中的 hugTipDismissed 状态,而不是组件内的局部变量。请在应用此建议后,手动移除第 168 行的 let hugTipDismissed = false;

const handleDoubleClick = debounce(async (item: CommentType) => {
  if (!settingStore.enableCommentHug) return;
  // 首次双击提示
  if (!settingStore.showedCommentHugTip) {
    window.$dialog.warning({
      title: "抱一抱",
      content: "双击评论会向评论者发送「抱一抱」,是否继续?",
      positiveText: "继续",
      negativeText: settingStore.hugTipDismissed ? "取消且不再提示" : "取消",
      onPositiveClick: () => {
        settingStore.showedCommentHugTip = true;
        executeHug(item);
      },
      onNegativeClick: () => {
        if (settingStore.hugTipDismissed) {
          settingStore.showedCommentHugTip = true;
          settingStore.enableCommentHug = false;
        }
        settingStore.hugTipDismissed = true;
      },
    });

Comment on lines +373 to +374
settingStore.enableCommentHug = v;
if (v) settingStore.showedCommentHugTip = false;
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

当用户重新开启「抱一抱」功能时,也应该重置 hugTipDismissed 状态,以便用户能重新看到标准的“取消”提示,而不是“取消且不再提示”。

                settingStore.enableCommentHug = v;
                if (v) {
                  settingStore.showedCommentHugTip = false;
                  settingStore.hugTipDismissed = false;
                }

Comment on lines +53 to +54
/** 是否已显示过抱一抱提示 */
showedCommentHugTip: boolean;
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

为了让「抱一抱」功能的取消提示状态能在组件销毁后依然保持,建议将 hugTipDismissed 状态也加入到 store 中。这能确保用户在整个应用中的体验一致性。

Suggested change
/** 是否已显示过抱一抱提示 */
showedCommentHugTip: boolean;
/** 是否已显示过抱一抱提示 */
showedCommentHugTip: boolean;
/** 是否已提示过“不再提示”选项 */
hugTipDismissed: boolean;

playerExpandAnimation: "up",
useOnlineService: true,
enableCommentHug: true,
showedCommentHugTip: false,
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

请在这里初始化新的 hugTipDismissed 状态。

Suggested change
showedCommentHugTip: false,
showedCommentHugTip: false,
hugTipDismissed: false,

@WorldSansha WorldSansha marked this pull request as draft March 5, 2026 13:35
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@WorldSansha
Copy link
Contributor Author

设置局部变量的原因:

用户可能已经忘了昨天取消过,看到「取消且不再提示」会觉得莫名其妙——"我什么时候被提示过了?为什么直接让我不再提示?"

局部变量(当前设计):

用户第一次双击 → 弹框,点「取消」
再次双击 → 按钮变成「取消且不再提示」(用户刚取消过,记忆还在,逻辑连贯)
关闭应用或刷新页面后,状态重置
下次打开又从普通「取消」开始,符合用户预期
核心区别在于:「取消」→「取消且不再提示」这个升级过程,只有在连续操作时才有意义。跨会话后用户的心理状态已经重置了,提示流程也应该重置。

Copy link
Owner

@imsyy imsyy left a comment

Choose a reason for hiding this comment

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

可彻底删除这个功能

@WorldSansha WorldSansha closed this Mar 5, 2026
@WorldSansha
Copy link
Contributor Author

可彻底删除这个功能

@WorldSansha WorldSansha reopened this Mar 5, 2026
@WorldSansha WorldSansha marked this pull request as ready for review March 5, 2026 14:28
@imsyy imsyy closed this in ecc047b Mar 9, 2026
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.

2 participants