Skip to content

Commit 729761d

Browse files
fix: lyrics.js 中的时间戳解析 (#2441)
1 parent c4f0c00 commit 729761d

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

src/utils/lyrics.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,9 @@ function parseLyric(lrc) {
6464

6565
for (const timestamp of lyricTimestamps.matchAll(extractTimestampRegex)) {
6666
const { min, sec, ms } = timestamp.groups;
67-
const rawTime = timestamp[0];
68-
const time = Number(min) * 60 + Number(sec) + Number(ms ?? 0) * 0.001;
67+
const validMs = ms?.slice(0, 2) ?? '00';
68+
const rawTime = `[${min}:${sec}.${validMs}]`;
69+
const time = Number(min) * 60 + Number(sec) + Number(validMs) * 0.01;
6970

7071
/** @type {ParsedLyric} */
7172
const parsedLyric = { rawTime, time, content: trimContent(content) };

0 commit comments

Comments
 (0)