From c59a100d4cf08b68c0273e5d8a5fb971e6cef4db Mon Sep 17 00:00:00 2001 From: pan93412 Date: Tue, 28 Dec 2021 17:58:31 +0800 Subject: [PATCH] =?UTF-8?q?refactor(views/library):=20=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E5=8F=96=E8=AF=8D=E9=80=BB=E8=BE=91=20(#1135)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * refactor(views/library): 修改取词逻辑 * refactor(views/library): clean up long-winded code Co-authored-by: 是虹川飴 Closed: #1133 Fixed: #1019 #1127 #1067 #1064 #1058 #1022 --- src/views/library.vue | 25 ++++++------------------- 1 file changed, 6 insertions(+), 19 deletions(-) diff --git a/src/views/library.vue b/src/views/library.vue index 5eb7b28..2dc1874 100644 --- a/src/views/library.vue +++ b/src/views/library.vue @@ -199,15 +199,6 @@ export default { pickedLyric() { if (this.lyric === undefined) return ''; let lyric = this.lyric.split('\n'); - lyric = lyric.filter(l => { - if (l.includes('纯音乐,请欣赏')) { - if (l.includes('作词') || l.includes('作曲')) { - return false; - } - return true; - } - return true; - }); let lineIndex = randomNum(0, lyric.length - 1); while (lineIndex + 4 > lyric.length) { lineIndex = randomNum(0, lyric.length - 1); @@ -290,16 +281,12 @@ export default { this.liked.songs[randomNum(0, this.liked.songs.length - 1)] ).then(data => { if (data.lrc !== undefined) { - let ifl = data.lrc.lyric.split('\n').filter(l => { - if (l.includes('作词')) { - if (l.includes('纯音乐,请欣赏') || l.includes('作词 : 无')) { - return false; - } - this.lyric = data.lrc.lyric; - return true + ifl; - } - return false; - }); + const isInstrumental = data.lrc.lyric + .split('\n') + .filter(l => l.includes('纯音乐,请欣赏')); + if (isInstrumental.length === 0) { + this.lyric = data.lrc.lyric; + } } }); },