- 移除 bd/mg 两平台及磁盘残留产物;清理 api-test 死脚本、musicSdk/message+options 死模块、infSign vendor - musicSdk/ 改名 sdk/;src/common、src/auth、src/apis 整体移入 sdk/,依赖方向定为 src → sdk 严格单向 - src/ 手写 JS 全量转 .ts,删除 JS 类型垫片 modules.d.ts;源码 import 统一 .ts 后缀 - Node 原生类型剥离直接运行 .ts(engines >=22.18),取消 tsc 发射产物,tsc 仅类型检查(pnpm typecheck) - 删除 kwdes 备用实现与 src/index.ts 转发垫片;测试移至 test/smoke-test.ts - common/request.ts 补显式导出类型;修复 set-cookie 单值形态、ApiError 类字段等隐患 验证:tsc 零错误,smoke-test 41/41
56 lines
1.6 KiB
TypeScript
56 lines
1.6 KiB
TypeScript
import type { HttpRequestObject } from '../types.ts'
|
|
import { httpFetch } from '../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
|
|
// console.log(body)
|
|
if (statusCode != 200 || body.code !== 0) throw new Error('获取热搜词失败')
|
|
// console.log(body)
|
|
return { source: 'tx', list: this.filterList(body.hotkey.data.vec_hotkey) }
|
|
},
|
|
filterList(rawList) {
|
|
return rawList.map(item => item.query)
|
|
},
|
|
}
|