From 5c96c83f9890d40cb548f1702f11506f56c95518 Mon Sep 17 00:00:00 2001 From: lyswhut Date: Mon, 2 Nov 2020 15:13:09 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A7=BB=E9=99=A4kg=E6=BA=90=E7=9A=84=E6=AD=8C?= =?UTF-8?q?=E8=AF=8D=E6=96=87=E4=BB=B6=E5=BC=80=E5=A4=B4=E7=9A=84=E7=A9=BA?= =?UTF-8?q?=E7=99=BD=E5=AD=97=E7=AC=A6=E4=B8=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- publish/changeLog.md | 10 +--------- src/renderer/components/core/Player.vue | 26 +++++++++---------------- src/renderer/store/modules/player.js | 9 +++++++++ src/renderer/utils/music/kg/lyric.js | 1 + 4 files changed, 20 insertions(+), 26 deletions(-) diff --git a/publish/changeLog.md b/publish/changeLog.md index b183e271..a24f93b0 100644 --- a/publish/changeLog.md +++ b/publish/changeLog.md @@ -1,11 +1,3 @@ -### 新增 - -- 播放详情页新增歌曲评论加载显示(某些平台暂不支持显示子评论) - ### 优化 -- 修改播放详情页的歌曲图片的显示效果 - -### 修复 - -- 修复小芸源音乐搜索结果最多只有20条搜索结果的问题 +- 移除kg源的歌词文件开头的空白字符串 diff --git a/src/renderer/components/core/Player.vue b/src/renderer/components/core/Player.vue index 9f6d9053..f7d2442b 100644 --- a/src/renderer/components/core/Player.vue +++ b/src/renderer/components/core/Player.vue @@ -667,23 +667,15 @@ export default { } }, setLrc(targetSong) { - this.musicInfo.lrc = targetSong.lrc - this.musicInfo.tlrc = targetSong.tlrc - - let lrcP = this.musicInfo.lrc && this.musicInfo.tlrc != null - ? Promise.resolve() - : this.getLrc(targetSong).then(() => { - this.musicInfo.lrc = targetSong.lrc - this.musicInfo.tlrc = targetSong.tlrc - }) - - lrcP - .catch(() => { - this.status = this.statusText = this.$t('core.player.lyric_error') - }).finally(() => { - this.handleUpdateWinLyricInfo('lyric', { lrc: this.musicInfo.lrc, tlrc: this.musicInfo.tlrc }) - this.setLyric() - }) + this.getLrc(targetSong).then(() => { + this.musicInfo.lrc = targetSong.lrc + this.musicInfo.tlrc = targetSong.tlrc + }).catch(() => { + this.status = this.statusText = this.$t('core.player.lyric_error') + }).finally(() => { + this.handleUpdateWinLyricInfo('lyric', { lrc: this.musicInfo.lrc, tlrc: this.musicInfo.tlrc }) + this.setLyric() + }) }, handleRemoveMusic() { this.stopPlay() diff --git a/src/renderer/store/modules/player.js b/src/renderer/store/modules/player.js index 16fbc8a0..80a38b5b 100644 --- a/src/renderer/store/modules/player.js +++ b/src/renderer/store/modules/player.js @@ -59,6 +59,15 @@ const actions = { }, getLrc({ commit, state }, musicInfo) { if (lrcRequest && lrcRequest.cancelHttp) lrcRequest.cancelHttp() + if (musicInfo.lrc && musicInfo.tlrc != null) { + if (musicInfo.lrc.startsWith('\ufeff[id:$00000000]')) { + let str = musicInfo.lrc.replace('\ufeff[id:$00000000]\n', '') + commit('setLrc', { musicInfo, lyric: str, tlyric: musicInfo.tlrc }) + } + return Promise.resolve() + } + + lrcRequest = music[musicInfo.source].getLyric(musicInfo) return lrcRequest.promise.then(({ lyric, tlyric }) => { lrcRequest = null diff --git a/src/renderer/utils/music/kg/lyric.js b/src/renderer/utils/music/kg/lyric.js index e5398e24..d0f4f903 100644 --- a/src/renderer/utils/music/kg/lyric.js +++ b/src/renderer/utils/music/kg/lyric.js @@ -3,6 +3,7 @@ import { decodeLyric } from './util' const parseLyric = str => { str = str.replace(/(?:<\d+,\d+,\d+>|\r)/g, '') + if (str.startsWith('\ufeff[id:$00000000]')) str = str.replace('\ufeff[id:$00000000]\n', '') let trans = str.match(/\[language:([\w=\\/+]+)\]/) let tlyric if (trans) {