Skip to content
This repository was archived by the owner on Mar 10, 2026. It is now read-only.

Commit 45ef04b

Browse files
committed
fix:lrc
1 parent 5a5b049 commit 45ef04b

1 file changed

Lines changed: 7 additions & 8 deletions

File tree

src/util.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,15 @@ const trimLyric = (lyric) => {
3333
const result = []
3434
const lines = lyric.split('\n')
3535
for (const line of lines) {
36-
// 匹配两种格式:[mm:ss.xxx] 或 [hh:mm:ss]
37-
const match = line.match(/^\[(?:(\d{2}):)?(\d{2}):(\d{2})(?:\.(\d+))?\](.*)$/)
36+
// 匹配两种格式:[mm:ss.xx] 或 [mm:ss:xx]
37+
const match = line.match(/^\[(\d{2}):(\d{2})[.:](\d+)\](.*)$/)
3838
if (match) {
39-
const hours = match[1] ? parseInt(match[1], 10) : 0
40-
const minutes = parseInt(match[2], 10)
41-
const seconds = parseInt(match[3], 10)
42-
const milliseconds = match[4] ? parseInt(match[4].padEnd(3, '0').slice(0, 3), 10) : 0
39+
const minutes = parseInt(match[1], 10)
40+
const seconds = parseInt(match[2], 10)
41+
const milliseconds = parseInt(match[3].padEnd(3, '0').slice(0, 3), 10)
4342
result.push({
44-
time: hours * 3600000 + minutes * 60000 + seconds * 1000 + milliseconds,
45-
text: match[5]
43+
time: minutes * 60000 + seconds * 1000 + milliseconds,
44+
text: match[4]
4645
})
4746
}
4847
}

0 commit comments

Comments
 (0)