fix: 网易云部分歌曲无法被搜索 (#2666)

* fix: 网易云部分歌曲无法被搜索

将搜索请求由原有 eapiRequest 改为通过 httpFetch 调用 /eapi/search/song/list/page 并使用 eapi 加密表单;调整导入(使用 eapi)、移除部分注释和冗余代码。更新结果解析以兼容新响应结构(使用 item.baseInfo.simpleSongData、result.data.resources 和 result.data.totalCount 等字段),并保留原有的分页与重试逻辑。

* update

* update

---------

Co-authored-by: lyswhut <lyswhut@qq.com>
This commit is contained in:
ikun0014
2026-01-31 12:36:28 +08:00
committed by GitHub
co-authored by lyswhut
parent d5c54b770f
commit 593d8327b2
2 changed files with 18 additions and 7 deletions
+17 -7
View File
@@ -10,12 +10,21 @@ export default {
page: 0,
allPage: 1,
musicSearch(str, page, limit) {
const searchRequest = eapiRequest('/api/cloudsearch/pc', {
s: str,
type: 1, // 1: 单曲, 10: 专辑, 100: 歌手, 1000: 歌单, 1002: 用户, 1004: MV, 1006: 歌词, 1009: 电台, 1014: 视频
limit,
total: page == 1,
// const searchRequest = eapiRequest('/api/cloudsearch/pc', {
// s: str,
// type: 1, // 1: 单曲, 10: 专辑, 100: 歌手, 1000: 歌单, 1002: 用户, 1004: MV, 1006: 歌词, 1009: 电台, 1014: 视频
// limit,
// total: page == 1,
// offset: limit * (page - 1),
// })
const searchRequest = eapiRequest('/api/search/song/list/page', {
keyword: str,
needCorrect: '1',
channel: 'typing',
offset: limit * (page - 1),
scene: 'normal',
total: page == 1,
limit,
})
return searchRequest.promise.then(({ body }) => body)
},
@@ -30,6 +39,7 @@ export default {
// console.log(rawList)
if (!rawList) return []
return rawList.map(item => {
item = item.baseInfo.simpleSongData
const types = []
const _types = {}
let size
@@ -87,12 +97,12 @@ export default {
return this.musicSearch(str, page, limit).then(result => {
// console.log(result)
if (!result || result.code !== 200) return this.search(str, page, limit, retryNum)
let list = this.handleResult(result.result.songs || [])
let list = this.handleResult(result.data.resources || [])
// console.log(list)
if (list == null) return this.search(str, page, limit, retryNum)
this.total = result.result.songCount || 0
this.total = result.data.totalCount || 0
this.page = page
this.allPage = Math.ceil(this.total / this.limit)