From a81fe6ff7fe27b06ca301d311568c666ed7f178a Mon Sep 17 00:00:00 2001 From: lyswhut Date: Fri, 28 Nov 2025 12:06:17 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8DMG=E6=9C=80=E6=96=B0=E8=AF=84?= =?UTF-8?q?=E8=AE=BA=E7=BF=BB=E9=A1=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/renderer/utils/musicSdk/mg/comment.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/renderer/utils/musicSdk/mg/comment.js b/src/renderer/utils/musicSdk/mg/comment.js index d8c4693f..dfa1d4b0 100644 --- a/src/renderer/utils/musicSdk/mg/comment.js +++ b/src/renderer/utils/musicSdk/mg/comment.js @@ -6,6 +6,7 @@ export default { _requestObj: null, _requestObj2: null, _requestObj3: null, + lastCommentIds: new Map(), async getComment(musicInfo, page = 1, limit = 20) { if (this._requestObj) this._requestObj.cancelHttp() if (!musicInfo.songId) { @@ -13,9 +14,11 @@ export default { if (!id) throw new Error('获取评论失败') musicInfo.songId = id } - + if (page === 1) this.lastCommentIds.clear() + const lastCommentId = this.lastCommentIds.get(String(page)) || '' + if (!lastCommentId && page > 1) throw new Error('获取评论失败') // const _requestObj = httpFetch(`https://music.migu.cn/v3/api/comment/listComments?targetId=${musicInfo.songId}&pageSize=${limit}&pageNo=${page}`, { - const _requestObj = httpFetch(`https://app.c.nf.migu.cn/MIGUM3.0/user/comment/stack/v1.0?pageSize=${limit}&queryType=1&resourceId=${musicInfo.songId}&resourceType=2&start=${(page - 1) * limit}`, { + const _requestObj = httpFetch(`https://app.c.nf.migu.cn/MIGUM3.0/user/comment/stack/v1.0?pageSize=${limit}&queryType=1&resourceId=${musicInfo.songId}&resourceType=2&commentId=${lastCommentId}`, { headers: { 'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1', // Referer: 'https://music.migu.cn', @@ -25,7 +28,9 @@ export default { // console.log(body) if (statusCode != 200 || body.code !== '000000') throw new Error('获取评论失败') const total = parseInt(body.data.commentNums) - return { source: 'mg', comments: this.filterComment(body.data.comments), total, page, limit, maxPage: Math.ceil(total / limit) || 1 } + const list = this.filterComment(body.data.comments) + this.lastCommentIds.set(String(page + 1), list.length ? list[list.length - 1].id : '') + return { source: 'mg', comments: list, total, page, limit, maxPage: Math.ceil(total / limit) || 1 } }, async getHotComment(musicInfo, page = 1, limit = 20) { if (this._requestObj2) this._requestObj2.cancelHttp()