🦄 refactor: 合并任务栏歌词相关 IPC 通道 by apoint123 · Pull Request #860 · imsyy/SPlayer
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!
此拉取请求旨在重构任务栏歌词功能的相关 IPC(进程间通信)通道。通过合并之前分散的通道,代码库变得更加模块化和易于扩展。这一改变简化了主进程和渲染进程之间的数据同步机制,为未来功能的开发和维护奠定了更坚实的基础。
Highlights
- IPC 通道合并: 将任务栏歌词相关的多个独立 IPC 通道合并为一个统一的
TASKBAR_IPC_CHANNELS,并通过SyncStatePayload广播各种状态更新(如歌曲信息、歌词、播放状态、配置和主题)。 - 类型定义重构: 重构并重新组织了共享类型定义,创建了
src/types/shared/play-mode.ts和src/types/shared/taskbar-ipc.ts,并将其统一导出到src/types/shared/index.ts。 - Vite 配置优化: 在
electron.vite.config.ts中集中管理了别名解析,提高了配置的一致性并减少了冗余。 - 任务栏歌词窗口可见性管理: 在
TaskbarLyricWindow中引入了setVisibility和handleFadeDone方法,以更健壮地控制任务栏歌词窗口的可见性和淡入淡出效果,包括处理播放状态和暂停时显示状态。 - 前端 IPC 集成更新: 更新了
useInit.ts和PlayerIpc.ts,以使用新的统一 IPC 通道和updateTaskbarConfig函数来发送任务栏歌词设置。 - 任务栏歌词视图逻辑更新: 修改了
TaskbarLyric/index.vue以监听新的SYNC_STATE和SYNC_TICK通道,处理合并后的数据负载,并实现了带有模糊效果的淡入淡出逻辑。
Changelog
- electron.vite.config.ts
- 集中化了 Vite 配置中的别名解析
- 更新了
MainEnv的导入方式为类型导入
- electron/main/ipc/ipc-taskbar.ts
- 重构了任务栏 IPC 处理逻辑,使用统一的通道和
SyncStatePayload - 引入了
getTaskbarConfig、updateWindowVisibility和updateWindowLayout函数 - 移除了多个独立的 IPC 监听器
- 重构了任务栏 IPC 处理逻辑,使用统一的通道和
- electron/main/ipc/ipc-tray.ts
- 更新了
PlayModePayload的导入方式为类型导入
- 更新了
- electron/main/tray/index.ts
- 更新了
RepeatModeType、ShuffleModeType、BrowserWindow和MenuItemConstructorOptions的导入方式为类型导入
- 更新了
- electron/main/windows/taskbar-lyric-window.ts
- 添加了
isFadingOut状态 - 实现了
setVisibility和handleFadeDone方法来控制窗口可见性和淡入淡出效果
- 添加了
- src/composables/useInit.ts
- 重新排序了导入语句
- 添加了
updateTaskbarConfig导入 - 将多个任务栏歌词设置的
watch语句合并为两个,并使用updateTaskbarConfig
- src/core/player/PlayModeManager.ts
- 更新了
SongType、RepeatModeType、ShuffleModeType和MessageReactive的导入方式为类型导入 - 调整了播放模式类型的导入路径
- 更新了
- src/core/player/PlayerController.ts
- 更新了
RepeatModeType和ShuffleModeType的导入方式为类型导入 - 重新排序了导入语句
- 将
toggleTaskbarLyric替换为updateTaskbarConfig({ enabled: show })
- 更新了
- src/core/player/PlayerIpc.ts
- 重构了任务栏歌词 IPC 函数,使用新的
TASKBAR_IPC_CHANNELS和SyncStatePayload - 引入了
updateTaskbarConfig、broadcastTaskbarState和broadcastTaskbarTick函数 - 移除了旧的独立
send函数
- 重构了任务栏歌词 IPC 函数,使用新的
- src/stores/status.ts
- 更新了多个类型的导入方式为类型导入
- 调整了播放模式类型的导入路径
- src/types/shared.ts
- 重命名为
src/types/shared/play-mode.ts - 移除了文件概述注释
- 重命名为
- src/types/shared/index.ts
- 新增文件,用于导出
play-mode和taskbar-ipc类型
- 新增文件,用于导出
- src/types/shared/taskbar-ipc.ts
- 新增文件,定义了
TaskbarConfig、TrackData、PlaybackState、LyricData、ThemeColorData、SyncTickPayload、SyncStatePayload类型和TASKBAR_IPC_CHANNELS常量
- 新增文件,定义了
- src/utils/format.ts
- 重新排序了导入语句
- 更新了
getPlayerInfoObj以使用musicStore.playSong作为备用 - 更新了多个类型的导入方式为类型导入
- src/utils/initIpc.ts
- 添加了
TaskbarConfig类型导入 - 重构了任务栏歌词的初始 IPC 数据发送逻辑,使用带有
full-hydration负载的broadcastTaskbarState
- 添加了
- src/views/TaskbarLyric/index.vue
- 更新了导入语句,使用新的共享类型和 IPC 通道
- 重构了状态管理以处理
SyncStatePayload和SyncTickPayload - 移除了
isVisible计算属性 - 更新了
rootStyle以支持淡入淡出效果 - 调整了窗口大小调整逻辑
- 移除了
contentStyle计算属性 - 添加了
configMap和applyConfigToStore函数 - 实现了带有模糊效果的淡入淡出逻辑
- tsconfig.node.json
- 更新了路径配置,以引用新的
src/types/shared目录而非单个src/types/shared.ts文件
- 更新了路径配置,以引用新的
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.
-
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. ↩