修复歌词解析问题

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