- 删除旧 sdk/request.ts,全部 import 收敛到 sdk/common/request.ts(85 文件) - 注释死代码 630+ 行、裸 console.log 吞错 6 处、未使用符号 26 处清零 - bili 状态校验去重;utils DNS 预解析失败日志改 warn 带上下文 - CODE-AUDIT.md:第四节 P2 清理记录 + 第八节线索逐条复核结论(kw/kg/tx/wy parse 骨架相似实质各异,不抽公共层)
54 lines
1.6 KiB
TypeScript
54 lines
1.6 KiB
TypeScript
import type { HttpRequestObject } from '../types.ts'
|
|
import { httpFetch } from '../common/request.ts'
|
|
|
|
export default {
|
|
_requestObj: null as HttpRequestObject | null,
|
|
async getList(retryNum = 0) {
|
|
if (this._requestObj) this._requestObj.cancelHttp()
|
|
if (retryNum > 2) return Promise.reject(new Error('try max num'))
|
|
|
|
// const _requestObj = httpFetch('https://c.y.qq.com/splcloud/fcgi-bin/gethotkey.fcg', {
|
|
// method: 'get',
|
|
// headers: {
|
|
// Referer: 'https://y.qq.com/portal/player.html',
|
|
// },
|
|
// })
|
|
const _requestObj = httpFetch('https://u.y.qq.com/cgi-bin/musicu.fcg', {
|
|
method: 'post',
|
|
body: {
|
|
comm: {
|
|
ct: '19',
|
|
cv: '1803',
|
|
guid: '0',
|
|
patch: '118',
|
|
psrf_access_token_expiresAt: 0,
|
|
psrf_qqaccess_token: '',
|
|
psrf_qqopenid: '',
|
|
psrf_qqunionid: '',
|
|
tmeAppID: 'qqmusic',
|
|
tmeLoginType: 0,
|
|
uin: '0',
|
|
wid: '0',
|
|
},
|
|
hotkey: {
|
|
method: 'GetHotkeyForQQMusicPC',
|
|
module: 'tencent_musicsoso_hotkey.HotkeyService',
|
|
param: {
|
|
search_id: '',
|
|
uin: 0,
|
|
},
|
|
},
|
|
},
|
|
headers: {
|
|
Referer: 'https://y.qq.com/portal/player.html',
|
|
},
|
|
})
|
|
const { body, statusCode } = await _requestObj.promise
|
|
if (statusCode != 200 || body.code !== 0) throw new Error('获取热搜词失败')
|
|
return { source: 'tx', list: this.filterList(body.hotkey.data.vec_hotkey) }
|
|
},
|
|
filterList(rawList) {
|
|
return rawList.map(item => item.query)
|
|
},
|
|
}
|