From 507d495f3f25ff8ab79e5bffe1bf2ad9a7222717 Mon Sep 17 00:00:00 2001 From: lyswhut Date: Mon, 2 Sep 2019 01:36:03 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dhttp=20post=E8=AF=B7=E6=B1=82?= =?UTF-8?q?=E5=B0=81=E8=A3=85=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/renderer/store/modules/songList.js | 1 - src/renderer/utils/music/kg/songList.js | 23 ++++++++++++++--------- src/renderer/utils/request.js | 4 +++- src/renderer/views/SongList.vue | 1 - 4 files changed, 17 insertions(+), 12 deletions(-) diff --git a/src/renderer/store/modules/songList.js b/src/renderer/store/modules/songList.js index 28c83bd1..5a30fe14 100644 --- a/src/renderer/store/modules/songList.js +++ b/src/renderer/store/modules/songList.js @@ -72,7 +72,6 @@ const mutations = { state.list.limit = result.limit state.list.page = result.page state.list.key = key - console.log(result) }, setListDetail(state, { result, key }) { state.listDetail.list = result.list diff --git a/src/renderer/utils/music/kg/songList.js b/src/renderer/utils/music/kg/songList.js index 76b89433..283768f6 100644 --- a/src/renderer/utils/music/kg/songList.js +++ b/src/renderer/utils/music/kg/songList.js @@ -48,8 +48,14 @@ export default { return `http://www2.kugou.kugou.com/yueku/v9/special/single/${id}-5-9999.html` }, - getTagInfo(tagId) { - + /** + * 格式化播放数量 + * @param {*} num + */ + formatPlayCount(num) { + if (num > 100000000) return parseInt(num / 10000000) / 10 + '亿' + if (num > 10000) return parseInt(num / 1000) / 10 + '万' + return num }, filterInfoHotTag(rawData) { const result = [] @@ -112,19 +118,18 @@ export default { } ) return this._requestObj_listRecommend.promise.then(({ body }) => { - // if (body.status !== 1) return this.getSongListRecommend() - if (body.status !== 1) return [] - return this.filterList(body.data) + if (body.status !== 1) return this.getSongListRecommend() + return this.filterList(body.data.special_list) }) }, filterList(rawData) { return rawData.map(item => ({ - play_count: item.total_play_count, + play_count: item.total_play_count || this.formatPlayCount(item.play_count), id: item.specialid, author: item.nickname, name: item.specialname, - time: item.publish_time, - img: item.img, + time: item.publish_time || item.publishtime, + img: item.img || item.imgurl, grade: item.grade, desc: item.intro, })) @@ -227,8 +232,8 @@ export default { ) if (!tagId) tasks.push(this.getSongListRecommend()) // 如果是所有类别,则顺便获取推荐列表 return Promise.all(tasks).then(([list, info, recommendList]) => { + console.log(recommendList) if (recommendList) list.unshift(...recommendList) - console.log(info) return { list, ...info, diff --git a/src/renderer/utils/request.js b/src/renderer/utils/request.js index 11093b3d..897297f1 100644 --- a/src/renderer/utils/request.js +++ b/src/renderer/utils/request.js @@ -229,7 +229,9 @@ const fatchData = (url, method, options, callback) => { method, headers: Object.assign({}, headers, options.headers || {}), Origin: options.origin, - data: options.data, + body: options.body, + form: options.form, + formData: options.formData, timeout: options.timeout || 10000, json: options.format === undefined || options.format === 'json', }, (err, resp, body) => { diff --git a/src/renderer/views/SongList.vue b/src/renderer/views/SongList.vue index 7989fd81..8784175f 100644 --- a/src/renderer/views/SongList.vue +++ b/src/renderer/views/SongList.vue @@ -41,7 +41,6 @@ export default { watch: { sortId(n, o) { this.setSongList({ sortId: n }) - console.log(n) if (o === undefined && this.listPage !== 1) return this.getList(1).then(() => { this.listPage = this.listData.listPage