diff --git a/src/renderer/utils/music/kg/comment.js b/src/renderer/utils/music/kg/comment.js index 5e4adf85..17f99289 100644 --- a/src/renderer/utils/music/kg/comment.js +++ b/src/renderer/utils/music/kg/comment.js @@ -29,7 +29,8 @@ export default { const { body, statusCode } = await _requestObj2.promise // console.log(body) if (statusCode != 200 || body.err_code !== 0) throw new Error('获取热门评论失败') - return { source: 'kg', comments: this.filterComment(body.weightList || []) } + const total = body.weightList?.length ?? 0 + return { source: 'kg', comments: this.filterComment(body.weightList || []), total, page, limit, maxPage: 1 } }, async getReplyComment({ songmid, audioId }, replyId, page = 1, limit = 100) { if (this._requestObj2) this._requestObj2.cancelHttp() diff --git a/src/renderer/utils/music/kw/comment.js b/src/renderer/utils/music/kw/comment.js index 7c6a7cfe..39c49e04 100644 --- a/src/renderer/utils/music/kw/comment.js +++ b/src/renderer/utils/music/kw/comment.js @@ -28,7 +28,7 @@ export default { const { body, statusCode } = await _requestObj2.promise if (statusCode != 200 || body.result !== 'ok') throw new Error('获取热门评论失败') // console.log(body) - return { source: 'kw', comments: this.filterComment(body.rows) } + return { source: 'kw', comments: this.filterComment(body.rows), total: body.total, page, limit, maxPage: Math.ceil(body.total / limit) || 1 } }, filterComment(rawList) { if (!rawList) return [] diff --git a/src/renderer/utils/music/mg/comment.js b/src/renderer/utils/music/mg/comment.js index c3fab1a4..f8468b83 100644 --- a/src/renderer/utils/music/mg/comment.js +++ b/src/renderer/utils/music/mg/comment.js @@ -53,7 +53,7 @@ export default { const { body, statusCode } = await _requestObj2.promise // console.log(body) if (statusCode != 200 || body.returnCode !== '000000') throw new Error('获取热门评论失败') - return { source: 'mg', comments: this.filterComment(body.data.items) } + return { source: 'mg', comments: this.filterComment(body.data.items), total: body.data.itemTotal, page, limit, maxPage: Math.ceil(body.data.itemTotal / limit) || 1 } }, async getReplyComment(musicInfo, replyId, page = 1, limit = 10) { if (this._requestObj2) this._requestObj2.cancelHttp() diff --git a/src/renderer/utils/music/tx/comment.js b/src/renderer/utils/music/tx/comment.js index fee8c0ff..58afe59b 100644 --- a/src/renderer/utils/music/tx/comment.js +++ b/src/renderer/utils/music/tx/comment.js @@ -77,6 +77,7 @@ export default { if (this._requestObj) this._requestObj.cancelHttp() const _requestObj = httpFetch('http://c.y.qq.com/base/fcgi-bin/fcg_global_comment_h5.fcg', { + method: 'POST', headers: { 'User-Agent': 'Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)', }, @@ -110,6 +111,7 @@ export default { if (this._requestObj2) this._requestObj2.cancelHttp() const _requestObj2 = httpFetch('http://c.y.qq.com/base/fcgi-bin/fcg_global_comment_h5.fcg', { + method: 'POST', headers: { 'User-Agent': 'Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)', }, @@ -134,6 +136,9 @@ export default { source: 'tx', comments: this.filterComment(comment.commentlist), total: comment.commenttotal, + page, + limit, + maxPage: Math.ceil(comment.commenttotal / limit) || 1, } }, replaceEmoji(msg) { @@ -149,7 +154,8 @@ export default { }, filterComment(rawList) { return rawList.map(item => { - let time = item.rootcommentid ? parseInt(item.rootcommentid.substring(item.rootcommentid.lastIndexOf('_') + 1) + '000') : null + let time = parseInt(item.time + '000') + let timeStr = dateFormat2(time) if (item.middlecommentcontent) { let firstItem = item.middlecommentcontent[0] firstItem.avatarurl = item.avatarurl @@ -159,23 +165,23 @@ export default { item.middlecommentcontent.reverse() } return { - id: item.subcommentid, + id: `${item.rootcommentid}_${item.commentid}`, rootId: item.rootcommentid, text: item.rootcommentcontent ? this.replaceEmoji(item.rootcommentcontent).replace(/\\n/g, '\n').split('\n') : [], - time, - timeStr: time ? dateFormat2(time) : null, + time: item.rootcommentid == item.commentid ? time : null, + timeStr: item.rootcommentid == item.commentid ? timeStr : null, userName: item.rootcommentnick ? item.rootcommentnick.substring(1) : '', avatar: item.avatarurl, userId: item.encrypt_rootcommentuin, likedCount: item.praisenum, reply: item.middlecommentcontent ? item.middlecommentcontent.map(c => { - let index = c.subcommentid.lastIndexOf('_') + // let index = c.subcommentid.lastIndexOf('_') return { - id: c.subcommentid, + id: `sub_${item.rootcommentid}_${c.subcommentid}`, text: this.replaceEmoji(c.subcommentcontent).replace(/\\n/g, '\n').split('\n'), - time: parseInt(c.subcommentid.substring(index + 1) + '000'), - timeStr: dateFormat2(parseInt(c.subcommentid.substring(index + 1) + '000')), + time: c.subcommentid == item.commentid ? time : null, + timeStr: c.subcommentid == item.commentid ? timeStr : null, userName: c.replynick.substring(1), avatar: c.avatarurl, userId: c.encrypt_replyuin, diff --git a/src/renderer/utils/music/wy/comment.js b/src/renderer/utils/music/wy/comment.js index 5597b894..469e1e3a 100644 --- a/src/renderer/utils/music/wy/comment.js +++ b/src/renderer/utils/music/wy/comment.js @@ -104,7 +104,8 @@ export default { const { body, statusCode } = await _requestObj2.promise if (statusCode != 200 || body.code !== 200) throw new Error('获取热门评论失败') // console.log(body) - return { source: 'wy', comments: this.filterComment(body.data.hotComments) } + const total = body.data.hotComments?.length ?? 0 + return { source: 'wy', comments: this.filterComment(body.data.hotComments), total, page, limit, maxPage: 1 } }, filterComment(rawList) { return rawList.map(item => {