Merge branch 'dev' of github.com:lyswhut/lx-music-desktop into dev

This commit is contained in:
lyswhut
2020-09-29 08:46:23 +08:00
4 changed files with 26 additions and 9 deletions
@@ -94,6 +94,7 @@ export default {
this.$refs.dom_input.focus()
},
handleTemplistClick(index) {
console.log(index)
this.sendEvent('listClick', index)
},
handleFocus() {
@@ -101,8 +102,10 @@ export default {
this.sendEvent('focus')
},
handleBlur() {
this.focus = false
this.sendEvent('blur')
setTimeout(() => {
this.focus = false
this.sendEvent('blur')
}, 80)
},
handleSearch() {
this.hideList()
+9 -2
View File
@@ -158,6 +158,9 @@ const getUrl = (downloadInfo, isRefresh) => {
return url && !isRefresh ? Promise.resolve({ url }) : music[downloadInfo.musicInfo.source].getMusicUrl(downloadInfo.musicInfo, downloadInfo.type).promise
}
// 修复 1.1.x版本 酷狗源歌词格式
const fixKgLyric = lrc => /\[00:\d\d:\d\d.\d+\]/.test(lrc) ? lrc.replace(/(?:\[00:(\d\d:\d\d.\d+\]))/gm, '[$1') : lrc
/**
* 设置歌曲meta信息
* @param {*} downloadInfo
@@ -184,7 +187,8 @@ const saveMeta = (downloadInfo, filePath, isEmbedPic, isEmbedLyric) => {
})
: Promise.resolve(),
]
Promise.all(tasks).then(([imgUrl, lyrics]) => {
Promise.all(tasks).then(([imgUrl, lyrics = {}]) => {
if (lyrics.lyric) lyrics.lyric = fixKgLyric(lyrics.lyric)
setMeta(filePath, {
title: downloadInfo.musicInfo.name,
artist: downloadInfo.musicInfo.singer,
@@ -205,7 +209,10 @@ const downloadLyric = (downloadInfo, filePath) => {
? Promise.resolve({ lyric: downloadInfo.musicInfo.lrc, tlyric: downloadInfo.musicInfo.tlrc || '' })
: music[downloadInfo.musicInfo.source].getLyric(downloadInfo.musicInfo).promise
promise.then(lrcs => {
if (lrcs.lyric) saveLrc(filePath.replace(/(mp3|flac|ape|wav)$/, 'lrc'), lrcs.lyric)
if (lrcs.lyric) {
lrcs.lyric = fixKgLyric(lrcs.lyric)
saveLrc(filePath.replace(/(mp3|flac|ape|wav)$/, 'lrc'), lrcs.lyric)
}
})
}
+1 -3
View File
@@ -21,12 +21,10 @@ const parseLyric = str => {
let time = parseInt(result[2])
let ms = time % 1000
time /= 1000
let h = parseInt(time / 3600).toString().padStart(2, '0')
time %= 3600
let m = parseInt(time / 60).toString().padStart(2, '0')
time %= 60
let s = parseInt(time).toString().padStart(2, '0')
time = `${h}:${m}:${s}.${ms}`
time = `${m}:${s}.${ms}`
if (tlyric) tlyric[i] = `[${time}]${tlyric[i++][0]}`
return str.replace(result[1], time)
})