修复歌词解析问题

pull/930/merge
lyswhut 2022-03-14 15:37:44 +08:00
parent ea1d21a3ef
commit 0f11731c01
1 changed files with 7 additions and 3 deletions

View File

@ -88,6 +88,7 @@ export const lrcTools = {
offset2: 1, offset2: 1,
isOK: false, isOK: false,
lines: [], lines: [],
tags: [],
getWordInfo(str, str2) { getWordInfo(str, str2) {
const offset = parseInt(str) const offset = parseInt(str)
const offset2 = parseInt(str2) const offset2 = parseInt(str2)
@ -132,7 +133,7 @@ export const lrcTools = {
this.isOK = false this.isOK = false
} }
} else { } else {
this.lines.push(line) this.tags.push(line)
} }
}, },
parse(lrc) { parse(lrc) {
@ -143,12 +144,15 @@ export const lrcTools = {
tools.offset = 1 tools.offset = 1
tools.offset2 = 1 tools.offset2 = 1
tools.lines = [] tools.lines = []
tools.tags = []
for (const line of lines) { for (const line of lines) {
if (!tools.isOK) return '' if (!tools.isOK) return ''
tools.parseLine(line) tools.parseLine(line)
} }
if (!tools.lines.length) return ''
return tools.lines.length ? tools.lines.join('\n') : '' let lrcs = tools.lines.join('\n')
if (tools.tags.length) lrcs = `${tools.tags.join('\n')}\n${lrcs}`
return lrcs
}, },
} }