Skip to content

🦄 refactor: 拆分单个播放模式按钮为两个#685

Merged
imsyy merged 11 commits into
SPlayer-Dev:devfrom
apoint123:refactor/split-playback-mode-button
Dec 30, 2025
Merged

🦄 refactor: 拆分单个播放模式按钮为两个#685
imsyy merged 11 commits into
SPlayer-Dev:devfrom
apoint123:refactor/split-playback-mode-button

Conversation

@apoint123
Copy link
Copy Markdown
Member

拆分单个播放模式按钮为两个,以更好地适配 SMTC 的双按钮播放模式,同时也和大部分其他播放器的双按钮设计保持一致

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

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

本次拉取请求旨在通过将播放模式控制从单一按钮拆分为独立的循环和随机模式按钮,来提升用户体验和系统兼容性。这一改变不仅使得播放器能更好地与 Windows 系统的 SMTC 媒体控制功能集成,也使其播放模式设计与市面上大多数音乐播放器保持了一致。通过对播放器核心逻辑和状态管理的全面重构,确保了新模式的稳定性和可扩展性,并优化了“心动模式”的实现。

Highlights

  • 播放模式拆分: 将单一的播放模式按钮拆分为“循环模式”和“随机模式”两个独立按钮,以更好地适配 SMTC (System Media Transport Controls) 的双按钮设计,并与其他主流播放器保持一致。
  • 内部逻辑重构: 播放器核心逻辑 (PlayerController) 和状态管理 (status store) 进行了重构,引入了 RepeatModeTypeShuffleModeType 新类型,分别管理循环和随机播放状态。
  • 心动模式优化: “心动模式”现在作为随机模式的一种特殊状态,并新增了 interleaveListscleanRecommendations 辅助函数,用于更智能地混合和清理推荐歌曲。
  • SMTC 同步更新: Electron 主进程中的托盘 IPC 和 SMTC 播放模式同步逻辑已更新,以支持新的双模式控制。
  • 移除旧模式控制器: 移除了 PlayModeController 类,其功能已整合到 PlayerControllerstatus store 中。
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.

@apoint123 apoint123 marked this pull request as draft December 29, 2025 12:29
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

本次重构将单一的播放模式按钮拆分为独立的循环和随机播放按钮,以适配 SMTC 并与其他播放器设计保持一致,这是一个很好的改进。代码整体实现清晰,尤其是在 PlayerController 中对播放模式逻辑的重写,使得状态管理更加直观。

我提出了一些建议以进一步提升代码质量:

  1. electron 的 IPC 通信中,为播放模式数据使用明确的 TypeScript 类型,以增强类型安全。
  2. PlayerRightMenu.vue 中,简化模板中重复的 v-if 条件。
  3. PlayerController.tsstatus.ts 中,将重复的随机模式切换逻辑提取为公共函数,以提高代码复用性和一致性。

这些调整将有助于提高代码的可维护性和健壮性。总体来说,这是一次高质量的重构。

Comment thread electron/main/ipc/ipc-tray.ts Outdated
Comment thread electron/main/tray/index.ts Outdated
Comment thread src/components/Player/PlayerRightMenu.vue Outdated
Comment thread src/core/player/PlayerController.ts Outdated
Comment thread src/stores/status.ts
@apoint123 apoint123 force-pushed the refactor/split-playback-mode-button branch from a27002e to fd8ab8c Compare December 29, 2025 18:42
@apoint123 apoint123 marked this pull request as ready for review December 29, 2025 20:35
@apoint123
Copy link
Copy Markdown
Member Author

/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 对播放模式进行了重构,将原先的单一播放模式状态拆分为独立的循环模式和随机/心动模式,这是一个非常棒的改进。代码结构因此变得更加清晰和易于维护,特别是引入了 PlayModeManager 来统一管理播放模式相关的复杂逻辑,并创建了 shared.ts 来共享类型定义,这些都是很好的实践。

我仔细审查了代码,并提出了一些可以进一步优化代码可读性和可维护性的建议,主要集中在新引入的逻辑中。整体而言,这是一次高质量的重构。

Comment thread electron/main/tray/index.ts Outdated
Comment thread src/core/player/PlayModeManager.ts Outdated
Comment thread src/core/player/PlayModeManager.ts Outdated
Comment thread src/stores/status.ts
Comment thread src/stores/status.ts
@imsyy imsyy merged commit 5b4a7af into SPlayer-Dev:dev Dec 30, 2025
@apoint123 apoint123 deleted the refactor/split-playback-mode-button branch December 30, 2025 09:05
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