Skip to content

feat: 重构 LRC 解析逻辑以支持元数据格式的背景行和尾随背景行处理 - #177

Open
MoYingJi wants to merge 2 commits into
SPlayer-Dev:devfrom
MoYingJi:pr/feat/parse-lrc
Open

feat: 重构 LRC 解析逻辑以支持元数据格式的背景行和尾随背景行处理#177
MoYingJi wants to merge 2 commits into
SPlayer-Dev:devfrom
MoYingJi:pr/feat/parse-lrc

Conversation

@MoYingJi

@MoYingJi MoYingJi commented Aug 18, 2026

Copy link
Copy Markdown
Collaborator

改动类型

  • 新功能(feat)
  • 缺陷修复(fix)
  • 重构 / 优化(不改变对外行为)
  • 文档(docs)
  • 其他(请在「改动说明」中注明)

是否包含破坏性变更

  • 是(请在「改动说明」中详细描述)

改动说明

重构 parseLRC.ts,并

测试情况

已在本地测试

自查清单

  • 本 PR 只包含一个主要功能 / 修复,没有夹带无关改动
  • 已在本地完整测试通过;AI 生成的代码同样自行测试并审阅过,未做未经验证的提交
  • 已运行 pnpm format,并确认 pnpm typecheckpnpm lint 通过
  • 改动涉及原生模块时已 pnpm build:native 验证;未手写 native/*/index.d.ts
  • 已向 dev 分支提交

@MoYingJi
MoYingJi marked this pull request as ready for review August 18, 2026 16:09
@MoYingJi
MoYingJi requested a lite review from Copilot August 18, 2026 16:10

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

本 PR 重构了渲染端的 LRC 解析器(src/utils/lyric/parseLRC.ts),以更好地处理「空时间标签作为结束时间」以及「元数据格式背景行 / 行内尾随背景行」等场景,提升歌词时间轴与背景行识别的兼容性。

Changes:

  • 抽出 parseLrcLine / parseLrcPayload 分层解析流程,新增对元数据标签(含 bg)的处理,并支持行内尾随和声拆分为背景行。
  • 调整空时间标签的处理方式:用于回填上一行 endTime,最终返回时过滤掉空白行节点。
  • 更新对应单测断言以匹配新行为。

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
src/utils/lyric/parseLRC.ts 重构 LRC 解析流程,新增元数据 bg 行与尾随背景行拆分,并用空时间标签回填 endTime 后过滤空行
src/utils/lyric/parse.spec.ts 调整空时间标签相关测试期望以匹配“只保留结束时间戳、不保留空白行”的新行为

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +186 to +195
if (key === "bg") {
const lines = parseLrcPayload(value, detectBackground);
if (lines.length === 1) {
lines[0].isBG = true;
return lines;
}
}

return [];
}
@@ -65,10 +65,9 @@ describe("lyric parse", () => {
it("将空时间标签保留为结束上一行的空白时间节点", () => {
Comment on lines +197 to +199
// JSON 行(平台的扩展元数据)
if (line.startsWith("{")) return [];

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