refactor(sdk): musicSdk 全量迁移至 TypeScript
This commit is contained in:
1 parent
f289df4cd7
commit
1dfb7a59ca
83 files changed
+924
-732
No files matched your search
@@ -0,0 +1,19 @@
|
||||
import { httpFetch } from '../request.ts'
|
||||
import type { HttpRequestObject } from '../types.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('http://jadeite.migu.cn:7090/music_search/v3/search/hotword')
|
||||
const { body, statusCode } = await _requestObj.promise
|
||||
if (statusCode != 200 || body.code !== '000000') throw new Error('获取热搜词失败')
|
||||
// console.log(body, statusCode)
|
||||
return { source: 'mg', list: this.filterList(body.data.hotwords[0].hotwordList) }
|
||||
},
|
||||
filterList(rawList) {
|
||||
return rawList.filter(item => item.resourceType == 'song').map(item => item.word)
|
||||
},
|
||||
}
|
||||
Reference in new issue
Block a user