Skip to content

修复桌面歌词杂项 颜色、封面修复、显示翻译罗马音#837

Merged
imsyy merged 10 commits intodevfrom
dev-fix-02
Feb 8, 2026
Merged

修复桌面歌词杂项 颜色、封面修复、显示翻译罗马音#837
imsyy merged 10 commits intodevfrom
dev-fix-02

Conversation

@kazukokawagawa
Copy link
Collaborator

No description provided.

- 导出 `getThemeFromColor` 工具函数用于颜色主题计算
- 新增 IPC 通信通道传递主题色数据
- 在任务栏歌词组件中根据主题色动态调整文本颜色
- 监听主题相关设置变化并实时更新任务栏歌词颜色
在设置中添加“任务栏歌词跟随主题色”选项,允许用户控制任务栏歌词颜色是否与应用主题同步。当关闭时,歌词将恢复为默认颜色。
使用Data URL替代Blob URL存储音乐封面,避免跨窗口或跨进程引用失效导致的封面闪烁和消失问题。移除对BlobURLManager的依赖,简化封面处理逻辑。
在任务栏歌词组件中添加设置选项,允许用户控制是否显示翻译歌词和罗马音歌词。通过 IPC 将设置同步到主进程,确保前后端状态一致。
@kazukokawagawa kazukokawagawa marked this pull request as ready for review February 7, 2026 11:06
@gemini-code-assist
Copy link
Contributor

Summary of Changes

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

此拉取请求主要围绕桌面歌词功能进行了多项重要的增强和修复。它引入了桌面歌词与应用主题色同步的能力,解决了专辑封面显示不稳定问题,并增加了翻译和罗马音歌词的显示选项。此外,底层的歌词解析和 TTML 导出逻辑也得到了显著的重构和优化,提升了性能和代码可维护性。同时,还对下载管理功能进行了小幅改进。

Highlights

  • 桌面歌词主题色同步: 实现了桌面歌词与应用主题色同步的功能,包括根据主题色或专辑封面颜色动态更新歌词颜色,并通过 IPC 机制实时传递颜色数据。
  • 歌词解析优化与重构: 对 LRC 和 QRC 歌词解析逻辑进行了大幅优化和重构,包括改进时间戳解析精度、单次遍历计算逐字/逐行结束时间,以及使用双指针算法提升歌词对齐效率。
  • 专辑封面显示修复: 解决了专辑封面在跨窗口/进程引用时可能出现的闪烁或消失问题,通过将 Blob URL 替换为 Data URL 来确保封面稳定显示。
  • 支持显示翻译和罗马音歌词: 在桌面歌词中新增了显示翻译歌词和罗马音歌词的功能,并提供了相应的设置选项进行控制。
  • TTML 导出改进: 引入了 XmlNode 辅助类,使得 TTML (Timed Text Markup Language) 格式的歌词导出更加健壮和代码清晰。
  • 下载管理功能增强: 为下载管理器添加了移除下载任务的功能,允许用户从下载队列和活动任务中删除指定任务。
Changelog
  • electron/main/ipc/ipc-taskbar.ts
    • 新增 taskbar:set-theme-color IPC 处理器,用于将主题色数据转发至任务栏歌词窗口。
  • src/components/Setting/config/lyric.ts
    • 新增 taskbarLyricUseThemeColor 设置项,控制任务栏歌词是否跟随应用主题色。
  • src/composables/useInit.ts
    • 更新 taskbar:broadcast-settings IPC 消息,使其包含 showTranshowRoma 设置,以便任务栏歌词窗口接收翻译和罗马音显示状态。
  • src/core/player/PlayerController.ts
    • 重构专辑封面处理逻辑,改用 Data URL 替代 Blob URL,以解决跨窗口/进程引用导致的封面显示问题。
  • src/core/player/PlayerIpc.ts
    • 新增 sendTaskbarThemeColor 函数,用于通过 IPC 向任务栏歌词窗口发送主题色信息。
  • src/core/resource/DownloadManager.ts
    • 实现了 removeDownload 方法,允许从活动下载任务和下载队列中移除指定任务。
  • src/stores/setting.ts
    • 在设置存储中添加 taskbarLyricUseThemeColor 状态,默认值为 true
  • src/utils/color.ts
    • 导出 getThemeFromColor 函数,使其可在其他模块中访问。
  • src/utils/initIpc.ts
    • 实现了根据用户设置和专辑封面动态计算并发送主题色到任务栏歌词窗口的逻辑。
    • 添加了 watch 效果,监听主题相关设置变化并更新任务栏歌词颜色。
  • src/utils/lyric/lyricParser.ts
    • 改进 parseTimeToMs 函数,通过字符串补齐处理提高毫秒解析精度,避免浮点数误差。
    • 优化 parseWordByWordLrcparseEnhancedLrc 函数,实现单次遍历计算逐字和逐行结束时间,移除 fixLineEndTimes
    • 重构 alignLyrics 函数,采用更高效的双指针算法实现 O(N) 复杂度,并返回深拷贝的歌词数据以确保不可变性。
    • 更新 parseQRCLyric 函数,使用新的 QRC 内容提取工具,并采用预编译的正则表达式。
    • 引入 XmlNode 辅助类,用于更清晰、更健壮地生成 TTML XML 结构。
  • src/utils/lyric/qrc-parser.ts
    • 新增文件:提供 extractLyricContent 函数,用于在不同环境下(浏览器/Node)从 QRC XML 中提取歌词内容。
  • src/views/Download/downloading.vue
    • 调整封面图片显示逻辑,优先使用 coverSize.s,否则回退到 cover
    • 更新 handleRemoveDownload 函数,使其支持 number | string 类型的 ID。
  • src/views/Download/layout.vue
    • 修改“全部播放”按钮的功能,使其仅播放已下载的歌曲。
  • src/views/TaskbarLyric/index.vue
    • 集成通过 IPC 接收到的主题色更新,动态调整歌词文本颜色。
    • 更新歌词显示逻辑,使其遵循 showTranshowRoma 设置,控制翻译和罗马音的显示。
    • 重构根样式应用方式,使用计算属性 rootStyle 封装样式逻辑。
Activity
  • 实现了桌面歌词颜色同步的初始版本。
  • 对歌词解析核心逻辑进行了性能和准确性方面的重构。
  • 引入了新的 QRC 歌词内容提取工具。
  • 更新了专辑封面处理方式,解决了显示问题。
  • 添加了下载任务移除功能。
  • 对下载视图和任务栏歌词显示进行了 UI 调整。
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

本次 PR 包含了一系列对桌面歌词功能的修复和增强,以及对歌词解析模块的重大重构。
主要变更包括:

  • 封面修复:通过使用 Data URL 替代 Blob URL,彻底解决了跨窗口(如任务栏歌词)引用封面时闪烁和失效的问题。
  • 任务栏歌词增强:新增了跟随应用主题色的功能,并支持根据设置显示或隐藏翻译和罗马音,提升了个性化和实用性。
  • 歌词解析器重构:对 LRC、QRC 和 TTML 的解析逻辑进行了全面优化。使用 matchAll 替代了带状态的 exec 循环,提高了代码的健壮性;将 alignLyrics 算法从 O(N*M) 优化到 O(N+M),显著提升了性能;并引入了 XmlNode 辅助类来生成 TTML,使代码更清晰、更不易出错。

整体来看,这是一次高质量的提交,不仅修复了现有问题、增加了新功能,还通过重构大幅提升了代码质量和性能。代码风格清晰,逻辑严谨。我只发现了一个可以使代码更健壮的微小改进点。

Comment on lines 410 to 414
const dataUrl = await new Promise<string>((resolve, reject) => {
reader.onload = () => resolve(reader.result as string);
reader.onerror = reject;
reader.readAsDataURL(blob);
});
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

为了增强健壮性,建议在 Promise 中也处理 onabort 事件。虽然在当前场景下被中止的可能性很低,但这是一种更完整的错误处理模式。

Suggested change
const dataUrl = await new Promise<string>((resolve, reject) => {
reader.onload = () => resolve(reader.result as string);
reader.onerror = reject;
reader.readAsDataURL(blob);
});
const dataUrl = await new Promise<string>((resolve, reject) => {
reader.onload = () => resolve(reader.result as string);
reader.onerror = reject;
reader.onabort = reject;
reader.readAsDataURL(blob);
});

kazukokawagawa and others added 3 commits February 7, 2026 19:16
当读取操作被中止时,未处理onabort事件可能导致Promise永远挂起。
添加onabort事件处理器来拒绝Promise,确保异常情况能被正确处理。
@kazukokawagawa kazukokawagawa self-assigned this Feb 8, 2026
@imsyy imsyy merged commit 09585ae into dev Feb 8, 2026
4 checks passed
@apoint123 apoint123 deleted the dev-fix-02 branch February 8, 2026 08:34
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