🦄 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.tssrc/types/shared/taskbar-ipc.ts,并将其统一导出到 src/types/shared/index.ts
  • Vite 配置优化: 在 electron.vite.config.ts 中集中管理了别名解析,提高了配置的一致性并减少了冗余。
  • 任务栏歌词窗口可见性管理: 在 TaskbarLyricWindow 中引入了 setVisibilityhandleFadeDone 方法,以更健壮地控制任务栏歌词窗口的可见性和淡入淡出效果,包括处理播放状态和暂停时显示状态。
  • 前端 IPC 集成更新: 更新了 useInit.tsPlayerIpc.ts,以使用新的统一 IPC 通道和 updateTaskbarConfig 函数来发送任务栏歌词设置。
  • 任务栏歌词视图逻辑更新: 修改了 TaskbarLyric/index.vue 以监听新的 SYNC_STATESYNC_TICK 通道,处理合并后的数据负载,并实现了带有模糊效果的淡入淡出逻辑。
Changelog
  • electron.vite.config.ts
    • 集中化了 Vite 配置中的别名解析
    • 更新了 MainEnv 的导入方式为类型导入
  • electron/main/ipc/ipc-taskbar.ts
    • 重构了任务栏 IPC 处理逻辑,使用统一的通道和 SyncStatePayload
    • 引入了 getTaskbarConfigupdateWindowVisibilityupdateWindowLayout 函数
    • 移除了多个独立的 IPC 监听器
  • electron/main/ipc/ipc-tray.ts
    • 更新了 PlayModePayload 的导入方式为类型导入
  • electron/main/tray/index.ts
    • 更新了 RepeatModeTypeShuffleModeTypeBrowserWindowMenuItemConstructorOptions 的导入方式为类型导入
  • electron/main/windows/taskbar-lyric-window.ts
    • 添加了 isFadingOut 状态
    • 实现了 setVisibilityhandleFadeDone 方法来控制窗口可见性和淡入淡出效果
  • src/composables/useInit.ts
    • 重新排序了导入语句
    • 添加了 updateTaskbarConfig 导入
    • 将多个任务栏歌词设置的 watch 语句合并为两个,并使用 updateTaskbarConfig
  • src/core/player/PlayModeManager.ts
    • 更新了 SongTypeRepeatModeTypeShuffleModeTypeMessageReactive 的导入方式为类型导入
    • 调整了播放模式类型的导入路径
  • src/core/player/PlayerController.ts
    • 更新了 RepeatModeTypeShuffleModeType 的导入方式为类型导入
    • 重新排序了导入语句
    • toggleTaskbarLyric 替换为 updateTaskbarConfig({ enabled: show })
  • src/core/player/PlayerIpc.ts
    • 重构了任务栏歌词 IPC 函数,使用新的 TASKBAR_IPC_CHANNELSSyncStatePayload
    • 引入了 updateTaskbarConfigbroadcastTaskbarStatebroadcastTaskbarTick 函数
    • 移除了旧的独立 send 函数
  • src/stores/status.ts
    • 更新了多个类型的导入方式为类型导入
    • 调整了播放模式类型的导入路径
  • src/types/shared.ts
    • 重命名为 src/types/shared/play-mode.ts
    • 移除了文件概述注释
  • src/types/shared/index.ts
    • 新增文件,用于导出 play-modetaskbar-ipc 类型
  • src/types/shared/taskbar-ipc.ts
    • 新增文件,定义了 TaskbarConfigTrackDataPlaybackStateLyricDataThemeColorDataSyncTickPayloadSyncStatePayload 类型和 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 通道
    • 重构了状态管理以处理 SyncStatePayloadSyncTickPayload
    • 移除了 isVisible 计算属性
    • 更新了 rootStyle 以支持淡入淡出效果
    • 调整了窗口大小调整逻辑
    • 移除了 contentStyle 计算属性
    • 添加了 configMapapplyConfigToStore 函数
    • 实现了带有模糊效果的淡入淡出逻辑
  • 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.

  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.