Skip to content

ci: 在 nightly 工作流中添加跨平台环境变量文件复制步骤 添加 Windows 和 macOS/Linux 系统的条件步骤,用于在 .env 文件不存在时从 .env.example 复制。这确保了 nightly 构建在不同操作系统上都能正确加载环境配置。#839

Open
kazukokawagawa wants to merge 11 commits intodevfrom
dev-fix-03

Conversation

@kazukokawagawa
Copy link
Collaborator

No description provided.

- 重构时间解析函数,使用纯数学运算替代字符串操作以提高性能
- 移除全局正则表达式,改为在函数内局部使用避免状态污染
- 在解析过程中直接计算结束时间,消除二次遍历
- 优化歌词对齐算法,使用双指针实现 O(N) 复杂度
- 改进 QRC 格式解析,提前编译正则并优化 XML 内容提取
- 统一默认单词持续时间处理逻辑
- 在 DownloadManager 中添加 removeDownload 方法,支持从队列和 store 中移除任务
- 修复下载页面中播放全部按钮的逻辑,仅对已下载歌曲生效
- 优化下载中页面的封面显示逻辑,统一使用 getCover 方法
- 将 handleRemoveDownload 的参数类型扩展为 number | string 以支持多种 ID 类型
- 使用字符串补齐替代浮点数计算,避免时间解析的精度误差
- 将 alignLyrics 改为纯函数,不再修改输入数组
- 引入 XmlNode 辅助类重构 TTML 生成逻辑,提高可读性
- 优化 QRC 内容提取的正则表达式,增强健壮性
将 QRC 歌词解析中的 LyricContent 提取逻辑重构为策略模式,根据运行环境自动选择 DOM 或正则解析器,提高代码可维护性和跨环境兼容性。
- 导出 `getThemeFromColor` 工具函数用于颜色主题计算
- 新增 IPC 通信通道传递主题色数据
- 在任务栏歌词组件中根据主题色动态调整文本颜色
- 监听主题相关设置变化并实时更新任务栏歌词颜色
在设置中添加“任务栏歌词跟随主题色”选项,允许用户控制任务栏歌词颜色是否与应用主题同步。当关闭时,歌词将恢复为默认颜色。
使用Data URL替代Blob URL存储音乐封面,避免跨窗口或跨进程引用失效导致的封面闪烁和消失问题。移除对BlobURLManager的依赖,简化封面处理逻辑。
在任务栏歌词组件中添加设置选项,允许用户控制是否显示翻译歌词和罗马音歌词。通过 IPC 将设置同步到主进程,确保前后端状态一致。
当读取操作被中止时,未处理onabort事件可能导致Promise永远挂起。
添加onabort事件处理器来拒绝Promise,确保异常情况能被正确处理。
添加 Windows 和 macOS/Linux 系统的条件步骤,用于在 .env 文件不存在时从 .env.example 复制。这确保了 nightly 构建在不同操作系统上都能正确加载环境配置。
@kazukokawagawa kazukokawagawa marked this pull request as ready for review February 7, 2026 12:19
@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!

此拉取请求主要侧重于提升应用程序的用户体验,特别是在歌词显示和媒体处理方面。它为任务栏歌词引入了动态主题色功能,并对底层的歌词解析引擎进行了显著的重构和性能优化,以提高准确性和稳定性。同时,通过改用 Data URL 解决了歌曲封面显示中的一个长期存在的问题。此外,还增强了下载管理功能,并提供了更灵活的歌词显示选项。

Highlights

  • 任务栏歌词主题色集成: 任务栏歌词现在可以跟随应用主题色,并新增了相关设置开关。主题色会根据应用设置和封面颜色动态计算,并通过 IPC 发送给任务栏歌词窗口。
  • 歌词解析优化: 对逐字 LRC、增强型 LRC 和 QRC 歌词的解析逻辑进行了大幅重构和优化。包括提高时间戳解析精度、单次遍历计算字词和行结束时间,以及使用双指针算法高效对齐歌词。新增了跨环境 QRC XML 内容提取工具。
  • 封面处理改为 Data URL: 将歌曲封面图片的加载方式从 Blob URL 切换为 Data URL,解决了跨窗口/进程引用失效导致的封面闪烁或消失问题,提高了稳定性。
  • 下载管理功能增强: 下载管理器新增了 removeDownload 方法,允许用户从活动下载列表和队列中移除指定的下载任务。
  • 任务栏歌词显示控制: 任务栏歌词现在支持根据 showTran(翻译歌词)和 showRoma(罗马音歌词)设置进行显示,提供了更精细的歌词显示控制。
Changelog
  • electron/main/ipc/ipc-taskbar.ts
    • 新增了用于设置任务栏主题色的 IPC 事件。
  • src/components/Setting/config/lyric.ts
    • 添加了新的设置项 taskbarLyricUseThemeColor,用于控制任务栏歌词是否跟随主题色。
  • src/composables/useInit.ts
    • 更新了任务栏设置广播,以包含翻译和罗马音歌词的显示偏好设置。
  • src/core/player/PlayerController.ts
    • 将歌曲封面的处理方式从 Blob URL 迁移到 Data URL,以提高稳定性。
  • src/core/player/PlayerIpc.ts
    • 新增了 sendTaskbarThemeColor 函数,用于通过 IPC 传输主题色数据。
  • src/core/resource/DownloadManager.ts
    • 实现了 removeDownload 方法,允许移除下载任务。
  • src/stores/setting.ts
    • 在设置存储中添加了 taskbarLyricUseThemeColor。
  • src/utils/color.ts
    • 导出了 getThemeFromColor 函数,以便在其他模块中使用。
  • src/utils/initIpc.ts
    • 实现了根据应用设置和封面艺术计算并发送任务栏主题色的逻辑。
  • src/utils/lyric/lyricParser.ts
    • 提高了 parseTimeToMs 的精度。
    • 优化了 parseWordByWordLrc 和 parseEnhancedLrc,实现了单次遍历计算结束时间。
    • 重构了 alignLyrics,采用了高效的双指针算法。
    • 更新了 parseQRCLyric,以使用新的 QRC 内容提取工具。
    • 引入了 XmlNode 辅助类,并重构了 lyricLinesToTTML 以生成更清晰的 TTML。
  • src/utils/lyric/qrc-parser.ts
    • 新增文件,用于跨环境 QRC XML 内容提取。
  • src/views/Download/downloading.vue
    • 更新了封面显示逻辑和 handleRemoveDownload 的签名。
  • src/views/Download/layout.vue
    • 修改了“全部播放”按钮,使其仅播放已下载的歌曲。
  • src/views/TaskbarLyric/index.vue
    • 添加了主题色状态和动态样式,并更新了翻译/罗马音歌词的设置处理。
Ignored Files
  • Ignored by pattern: .github/workflows/** (1)
    • .github/workflows/nightly.yml
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

本次 PR 主要包含了两大部分的更新:为任务栏歌词添加了跟随主题色的新功能,并对歌词解析器(lyricParser.ts)进行了一次重大的重构。

整体来看,代码质量非常高。特别是歌词解析器的重构,显著提升了性能、可维护性和代码健壮性。例如:

  • alignLyrics 函数的对齐算法从 O(N*M) 优化到了 O(N+M),效率大幅提升。
  • lyricLinesToTTML 函数改用 XmlNode 构建器来生成 XML,代码更清晰且不易出错。
  • 多个解析函数中,通过改用 matchAll 避免了带状态的全局正则表达式可能引发的问题。

此外,将歌曲封面从 Blob URL 改为 Data URL,解决了跨窗口引用失效的问题,是一个很好的修复。

我发现了一个潜在的高危问题,在新增的 qrc-parser.ts 文件中,可能会因为未处理的 null 值导致运行时错误。

最后,PR 的标题(关于 CI 工作流)似乎与本次的代码变更内容(应用功能和重构)不符,建议修改标题以准确反映 PR 的内容。

return "";
}

return doc.documentElement.getAttribute("LyricContent") || "";
Copy link
Contributor

Choose a reason for hiding this comment

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

high

domParser 函数中,doc.documentElement 可能为 null,例如当解析的 XML 字符串只包含注释或处理指令时。直接访问 doc.documentElement.getAttribute 会导致抛出 TypeError。虽然外层有 try...catch 捕获,但更好的做法是添加一个空值检查来优雅地处理这种情况。

Suggested change
return doc.documentElement.getAttribute("LyricContent") || "";
return doc.documentElement?.getAttribute("LyricContent") || "";

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.

1 participant