修复tx源评论加载失败的问题

This commit is contained in:
lyswhut
2022-12-26 17:39:11 +08:00
parent 9c7661d1ae
commit 4594f2fd1f
2 changed files with 119 additions and 2 deletions
+21 -2
View File
@@ -1,5 +1,6 @@
import { httpFetch } from '../../request'
import { dateFormat2 } from '../../index'
import getMusicInfo from './musicInfo'
const emojis = {
e400846: '😘',
@@ -70,12 +71,28 @@ const emojis = {
e400432: '👑',
}
const songIdMap = new Map()
const promises = new Map()
export default {
_requestObj: null,
_requestObj2: null,
async getComment({ songId }, page = 1, limit = 20) {
async getSongId({ songId, songmid }) {
if (songId) return songId
if (songIdMap.has(songmid)) return songIdMap.get(songmid)
if (promises.has(songmid)) return (await promises.get(songmid)).songId
const promise = getMusicInfo(songmid)
promises.set(promise)
const info = await promise
songIdMap.set(songmid, info.songId)
promises.delete(songmid)
return info.songId
},
async getComment(mInfo, page = 1, limit = 20) {
if (this._requestObj) this._requestObj.cancelHttp()
const songId = await this.getSongId(mInfo)
const _requestObj = httpFetch('http://c.y.qq.com/base/fcgi-bin/fcg_global_comment_h5.fcg', {
method: 'POST',
headers: {
@@ -107,9 +124,11 @@ export default {
maxPage: Math.ceil(comment.commenttotal / limit) || 1,
}
},
async getHotComment({ songId }, page = 1, limit = 100) {
async getHotComment(mInfo, page = 1, limit = 100) {
if (this._requestObj2) this._requestObj2.cancelHttp()
const songId = await this.getSongId(mInfo)
const _requestObj2 = httpFetch('http://c.y.qq.com/base/fcgi-bin/fcg_global_comment_h5.fcg', {
method: 'POST',
headers: {