From 107bf53a39ed906580400507915b07168fddb7be Mon Sep 17 00:00:00 2001 From: memorydream <34763046+memorydream@users.noreply.github.com> Date: Sun, 1 May 2022 14:13:11 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E9=94=99=E8=AF=AF=E7=9A=84=E9=80=89?= =?UTF-8?q?=E6=8B=A9=E4=BA=86=E9=9F=B3=E6=BA=90=E8=B4=A8=E9=87=8F=20(#1589?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/track.js | 15 ++++++--------- src/utils/Player.js | 2 +- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/src/api/track.js b/src/api/track.js index 5b68082..490c91c 100644 --- a/src/api/track.js +++ b/src/api/track.js @@ -13,15 +13,12 @@ import { * 说明 : 使用歌单详情接口后 , 能得到的音乐的 id, 但不能得到的音乐 url, 调用此接口, 传入的音乐 id( 可多个 , 用逗号隔开 ), 可以获取对应的音乐的 url, * !!!未登录状态返回试听片段(返回字段包含被截取的正常歌曲的开始时间和结束时间) * @param {string} id - 音乐的 id,例如 id=405998841,33894312 - * @param {string} sqBr - flac(SQ)的比特率 - * @param {string} hiResBr - hi-res的比特率 */ -export function getMP3(id, sqBr, hiResBr) { - const getBr = (quality, sqBr, hiResBr) => { - if (quality === undefined) return 320000; - if (quality === 'flac' && sqBr) return sqBr; - if (quality === '999000' && hiResBr) return hiResBr; - return quality; +export function getMP3(id) { + const getBr = () => { + // 当返回的 quality >= 400000时,就会优先返回 hi-res + const quality = store.state.settings?.musicQuality ?? '320000'; + return quality === 'flac' ? '350000' : quality; }; return request({ @@ -29,7 +26,7 @@ export function getMP3(id, sqBr, hiResBr) { method: 'get', params: { id, - br: getBr(store.state.settings?.musicQuality, sqBr, hiResBr), + br: getBr(), }, }); } diff --git a/src/utils/Player.js b/src/utils/Player.js index 894d86e..0274dac 100644 --- a/src/utils/Player.js +++ b/src/utils/Player.js @@ -355,7 +355,7 @@ export default class { } _getAudioSourceFromNetease(track) { if (isAccountLoggedIn()) { - return getMP3(track.id, track.sq?.br, track.hr?.br).then(result => { + return getMP3(track.id).then(result => { if (!result.data[0]) return null; if (!result.data[0].url) return null; if (result.data[0].freeTrialInfo !== null) return null; // 跳过只能试听的歌曲