refactor(sdk): tipSearch 全删、歌词解码器归位、IPC 桥移除、api-source 层拆除
- 四平台 tipSearch 全部删除(永不做搜索联想),types 同步去掉 tipSearch 字段 - 歌词解码器归位:kg/krcDecode、tx/qrcDecode、kw/lyricDecode(原 common/ 下三处) - rendererIpc/ipcNames IPC 桥删除,SDK 纯服务端化 - supportQuality 由各平台 apis 内联导出(sdk/index 汇总),kg/kw/tx/wy 改直连 apis/*,api-source 旧层移除
This commit is contained in:
1 parent
3c51e4d06a
commit
66d06ef48a
25 files changed
+42
-342
No files matched your search
+2
-4
@@ -1,5 +1,5 @@
|
||||
import leaderboard from './leaderboard.ts'
|
||||
import { apis } from '../api-source.ts'
|
||||
import wyApi from '../apis/wy.ts'
|
||||
import getLyric from './lyric.ts'
|
||||
import getMusicInfo from './musicInfo.ts'
|
||||
import musicSearch from './musicSearch.ts'
|
||||
@@ -7,10 +7,8 @@ import songList from './songList.ts'
|
||||
import hotSearch from './hotSearch.ts'
|
||||
import comment from './comment.ts'
|
||||
import singer from './singer.ts'
|
||||
// import tipSearch from './tipSearch.ts'
|
||||
|
||||
const wy = {
|
||||
// tipSearch,
|
||||
leaderboard,
|
||||
musicSearch,
|
||||
songList,
|
||||
@@ -18,7 +16,7 @@ const wy = {
|
||||
comment,
|
||||
singer,
|
||||
getMusicUrl(songInfo, type) {
|
||||
return apis('wy').getMusicUrl!(songInfo, type)
|
||||
return wyApi.getMusicUrl(songInfo, type)
|
||||
},
|
||||
getLyric(songInfo) {
|
||||
return getLyric(songInfo.songmid)
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
import { httpFetch } from '../request.ts'
|
||||
import { weapi } from './utils/crypto.ts'
|
||||
import { formatSingerName } from '../utils.ts'
|
||||
import type { HttpRequestObject } from '../types.ts'
|
||||
|
||||
export default {
|
||||
requestObj: null as HttpRequestObject | null,
|
||||
cancelTipSearch() {
|
||||
if (this.requestObj && this.requestObj.cancelHttp) this.requestObj.cancelHttp()
|
||||
},
|
||||
tipSearchBySong(str) {
|
||||
this.cancelTipSearch()
|
||||
this.requestObj = httpFetch('https://music.163.com/weapi/search/suggest/web', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
referer: 'https://music.163.com/',
|
||||
origin: 'https://music.163.com/',
|
||||
},
|
||||
form: weapi({
|
||||
s: str,
|
||||
}),
|
||||
})
|
||||
return this.requestObj!.promise.then(({ statusCode, body }) => {
|
||||
if (statusCode != 200 || body.code != 200) return Promise.reject(new Error('请求失败'))
|
||||
return body.result.songs
|
||||
})
|
||||
},
|
||||
handleResult(rawData) {
|
||||
return rawData.map(info => `${info.name} - ${formatSingerName(info.artists, 'name')}`)
|
||||
},
|
||||
async search(str) {
|
||||
return this.tipSearchBySong(str).then(result => this.handleResult(result))
|
||||
},
|
||||
}
|
||||
Reference in new issue
Block a user