From 593d8327b228471fafc4d7864f59cfd26735ef22 Mon Sep 17 00:00:00 2001 From: ikun0014 Date: Sat, 31 Jan 2026 12:36:28 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E7=BD=91=E6=98=93=E4=BA=91=E9=83=A8?= =?UTF-8?q?=E5=88=86=E6=AD=8C=E6=9B=B2=E6=97=A0=E6=B3=95=E8=A2=AB=E6=90=9C?= =?UTF-8?q?=E7=B4=A2=20(#2666)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 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 --- publish/changeLog.md | 1 + src/renderer/utils/musicSdk/wy/musicSearch.js | 24 +++++++++++++------ 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/publish/changeLog.md b/publish/changeLog.md index 43a7a052..93357964 100644 --- a/publish/changeLog.md +++ b/publish/changeLog.md @@ -9,3 +9,4 @@ - 修复音量条在调整音量时实际音量与显示的数值不一致的问题(#2606) - 修复某些情况下搜索框的搜索按钮布局错位的问题(#2622) +- 修复 wyy 部分歌曲无法被搜索的问题(#2666, @ikun0014) diff --git a/src/renderer/utils/musicSdk/wy/musicSearch.js b/src/renderer/utils/musicSdk/wy/musicSearch.js index 32024996..be32384b 100644 --- a/src/renderer/utils/musicSdk/wy/musicSearch.js +++ b/src/renderer/utils/musicSdk/wy/musicSearch.js @@ -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)