feat: 重构 LRC 解析逻辑以支持元数据格式的背景行和尾随背景行处理 - #177
Open
MoYingJi wants to merge 2 commits into
Open
Conversation
MoYingJi
force-pushed
the
pr/feat/parse-lrc
branch
from
August 18, 2026 15:51
1a9eacb to
26fc27c
Compare
MoYingJi
marked this pull request as ready for review
August 18, 2026 16:09
Contributor
There was a problem hiding this comment.
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 []; | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
改动类型
是否包含破坏性变更
改动说明
重构
parseLRC.ts,并测试情况
已在本地测试
自查清单
pnpm format,并确认pnpm typecheck、pnpm lint通过pnpm build:native验证;未手写native/*/index.d.tsdev分支提交