Skip to content

给任务栏歌词支持了TTML的BG 然后给阿姨倒一杯卡布奇诺#954

Merged
imsyy merged 29 commits into
devfrom
dev-lrc
Mar 4, 2026
Merged

给任务栏歌词支持了TTML的BG 然后给阿姨倒一杯卡布奇诺#954
imsyy merged 29 commits into
devfrom
dev-lrc

Conversation

@kazukokawagawa
Copy link
Copy Markdown
Collaborator

No description provided.

将原本在 DesktopLyric 组件中定义的 getSafeEndTime 函数移至 src/utils/calc.ts 工具模块中,以便复用和保持代码结构清晰。函数逻辑保持不变,用于安全计算歌词行的结束时间。
重构歌词索引计算逻辑,将主歌词与背景歌词分离处理。引入 mainLyrics 数组存储非背景歌词,并维护与原歌词索引的映射。修复背景歌词在特定时间段内错误显示的问题,并正确计算其播放进度。同时优化歌词跳转检测,移除冗余的查找函数,复用工具函数 calculateLyricIndex。
将歌词时间轴计算中的行补偿参数从2改为1,以更准确地匹配歌词切换时机。
原逻辑仅基于背景行开始时间判断是否在播放时间窗口内,导致某些背景行因开始时间在窗口外而被错误跳过。现改为同时检查背景行的开始时间和结束时间,只要任意一个时间点落在当前播放窗口内,即视为匹配。
修复背景歌词时间窗口判断逻辑,当歌词有有效结束时间时,使用结束时间进行判断,否则使用开始时间判断。这确保了背景歌词在正确的时间范围内被缓存和显示。
修复背景歌词在时间窗口判断时,当歌词起始时间早于主窗口开始时间且无有效结束时间时,未正确处理的情况。原逻辑在无有效结束时间时会错误地将起始时间与主窗口比较,导致符合条件的背景歌词被遗漏。
修复背景歌词匹配时优先选择当前时间窗口内的歌词,而不是预滚动歌词。原逻辑在预滚动和普通歌词同时存在时可能选择错误,导致显示不匹配的歌词。
重构背景歌词选择算法,通过预计算安全结束时间避免重复计算。
移除原有的预滚动和正常窗口逻辑,改用基于所有权和重叠判断的简化算法。
@kazukokawagawa kazukokawagawa self-assigned this Feb 28, 2026
Copilot AI review requested due to automatic review settings February 28, 2026 11:31
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, 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

  • TTML背景歌词支持: 任务栏歌词现在支持显示TTML格式的背景歌词,增强了歌词的显示能力和用户体验。
  • 歌词处理逻辑重构: 对歌词处理逻辑进行了重大重构,引入了mainLyricsmainLyricIndex等新状态来区分主歌词和背景歌词,并优化了歌词索引和显示机制。
  • 通用工具函数提取: 将计算安全结束时间的getSafeEndTime函数从DesktopLyric组件中提取到src/utils/calc.ts,实现了代码复用和模块化。
  • 显示项属性增强: 更新了DisplayItem接口,增加了isActiveprogress属性,使得歌词显示更加灵活和精确。
Changelog
  • src/utils/calc.ts
    • 新增了getSafeEndTime函数,用于计算歌词行的安全结束时间。
  • src/views/DesktopLyric/index.vue
    • getSafeEndTime函数移动到src/utils/calc.ts
    • 更新了导入语句以从src/utils/calc.ts引入getSafeEndTime
  • src/views/TaskbarLyric/index.vue
    • 实现了对TTML背景歌词的支持。
    • 重构了歌词处理逻辑,分离了主歌词和背景歌词。
    • 引入了mainLyricsmainToRawIndexmainSafeEndsmainLyricIndexbgCache等新的响应式状态来管理歌词数据。
    • 修改了DisplayItem接口,增加了isActiveprogress属性。
    • 更新了歌词渲染逻辑,以显示背景歌词并利用新的isActiveprogress属性。
    • 移除了自定义的findLyricIndex函数,并改用src/utils/calc.ts中的calculateLyricIndex
    • 调整了监听器和初始化逻辑,以同步歌词索引。
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.

gemini-code-assist[bot]

This comment was marked as spam.

This comment was marked as spam.

kazukokawagawa and others added 16 commits March 1, 2026 15:34
在全局播放器设置中添加“显示评论数量”选项,允许用户控制是否在播放界面显示歌曲评论数量。同时优化了相关组件中的条件渲染逻辑和代码格式。
- 删除设置中的评论数量显示选项,不再支持完整/缩减/关闭模式
- 简化评论数量显示逻辑,仅根据全屏播放器元素设置决定是否显示
- 移除不再使用的代码和状态管理,减少代码复杂度
实现 TTML 歌词格式的背景歌词行提取器,支持解析带时间戳的歌词片段,并自动处理括号包装和翻译、罗马音等元数据。
从TTML歌词中提取背景歌词行并注入到对应的主歌词行后面,增强歌词显示的完整性
移除评论数量显示对设置项的依赖,始终在有评论数量时显示
优化任务栏歌词背景选择算法,使用评分机制选择最佳匹配行
- 重构 `extractTtmlBgLines` 为 `extractTtmlBgWithOwner`,返回包含背景歌词行及其所属段落信息的对象
- 在 `LyricManager.attachTtmlBgLines` 中优先使用段落时间锚点(pBeginMs/pEndMs)进行更精确的匹配
- 保留现有背景歌词的处理逻辑,仅在无背景歌词时注入新提取的内容
- 添加对背景歌词括号的规范化处理,确保显示一致性
- 通过 `order` 字段保持背景歌词的原始顺序
移除 TTML 解析器和歌词管理器中对背景歌词自动添加括号的冗余处理。
这些逻辑原本用于确保背景歌词被括号包裹,但实际场景中括号应由歌词源提供,
自动补全会导致重复括号或格式错误。现在统一依赖歌词源的原始格式。
将TTML背景行注入逻辑从通用解析流程中移除,改为仅在任务栏显示时单独处理。避免污染原始歌词数据,同时确保任务栏能正确显示带背景的逐字歌词。
新增任务栏歌词行间距设置,允许用户在 0.8 到 3.0 之间调整行高倍数
添加任务栏歌词的字体大小、主歌词缩放比例和副歌词缩放比例配置选项,允许用户自定义歌词显示样式
将任务栏歌词设置项的默认值从描述中移至新增的 defaultValue 字段,使配置结构更清晰,便于后续维护和扩展。
kazukokawagawa and others added 5 commits March 3, 2026 18:15
在歌词组切换的离开过渡前,手动计算并设置元素的绝对定位。
这确保了离开动画元素能基于其原始位置正确播放,避免因布局变化导致的视觉跳跃。
- 将原有的 lineHeight、fontSize、mainScale、subScale 配置拆分为 taskbar* 和 floating* 版本
- 在设置界面中根据当前显示模式分别显示和保存对应配置
- 支持向后兼容,从旧配置中读取默认值
将 getLineText 提取为公共导出函数,消除重复定义;在 rebuildMainLyrics 中预计算
mainBgMap 映射,将 updateBgCache 从每次索引变化时的 O(n) 遍历+评分简化为 O(1)
Map 查找。

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Comment thread src/core/player/LyricManager.ts Outdated
const ttmlContent = typeof ttml === "string" ? ttml : "";
if (ttmlContent) {
ttmlLines = parseTTML(this.cleanTTMLTranslations(ttmlContent)).lines || [];
const cleaned = this.cleanTTMLTranslations(ttmlContent);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

不用改

* @param lines 原始解析后的歌词行
* @param ttml 原始 TTML 文本
*/
public processTtmlForTaskbar(lines: LyricLine[], ttml: string): LyricLine[] {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

直接使用方法函数,此处不需要

@imsyy imsyy merged commit 1926144 into dev Mar 4, 2026
4 checks passed
@imsyy imsyy deleted the dev-lrc branch March 4, 2026 06:41
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.

3 participants