Skip to content

Commit 1786376

Browse files
committed
优化请求,修复加载bug
1 parent aa973ea commit 1786376

16 files changed

Lines changed: 48 additions & 27 deletions

File tree

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,3 +69,5 @@ dist
6969
publish/assets
7070

7171
publish/utils/githubToken.js
72+
73+
src/**/*-internal.js

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,16 @@ Project versioning adheres to [Semantic Versioning](http://semver.org/).
66
Commit convention is based on [Conventional Commits](http://conventionalcommits.org).
77
Change log format is based on [Keep a Changelog](http://keepachangelog.com/).
88

9+
## [0.3.4](https://github.com/lyswhut/lx-music-desktop/compare/v0.3.3...v0.3.4) - 2019-08-29
10+
11+
### 优化
12+
13+
- 减少接口不稳定带来的影响,适当增加请求等待时间
14+
15+
### 修复
16+
17+
- 修复播放过程中URL过期不会刷新URL的问题
18+
919
## [0.3.3](https://github.com/lyswhut/lx-music-desktop/compare/v0.3.2...v0.3.3) - 2019-08-29
1020

1121
### 修复

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "lx-music-desktop",
3-
"version": "0.3.3",
3+
"version": "0.3.4",
44
"description": "一个免费的音乐下载助手",
55
"main": "./dist/electron/main.js",
66
"productName": "lx-music-desktop",

publish/changeLog.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
### 修复
1+
### 优化
2+
3+
- 减少接口不稳定带来的影响,适当增加请求等待时间
24

3-
- **messoer**的接口已经关闭,暂时切换到临时接口使用,部分功能受限。。。
4-
- 修复设置界面更新出错时仍然显示更新下载中的问题
5-
- 修复手动定位播放进度条时存在偏差的问题
6-
- 屏蔽播放器中没有歌曲时对进度条的点击
5+
### 修复
76

7+
- 修复播放过程中URL过期不会刷新URL的问题

publish/version.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
{
2-
"version": "0.3.3",
3-
"desc": "<h3>修复</h3>\n<ul>\n<li><strong>messoer</strong>的接口已经关闭,暂时切换到临时接口使用,部分功能受限。。。</li>\n<li>修复设置界面更新出错时仍然显示更新下载中的问题</li>\n<li>修复手动定位播放进度条时存在偏差的问题</li>\n<li>屏蔽播放器中没有歌曲时对进度条的点击</li>\n</ul>\n",
2+
"version": "0.3.4",
3+
"desc": "<h3>优化</h3>\n<ul>\n<li>减少接口不稳定带来的影响,适当增加请求等待时间</li>\n</ul>\n<h3>修复</h3>\n<ul>\n<li>修复播放过程中URL过期不会刷新URL的问题</li>\n</ul>\n",
44
"history": [
5+
{
6+
"version": "0.3.3",
7+
"desc": "<h3>修复</h3>\n<ul>\n<li><strong>messoer</strong>的接口已经关闭,暂时切换到临时接口使用,部分功能受限。。。</li>\n<li>修复设置界面更新出错时仍然显示更新下载中的问题</li>\n<li>修复手动定位播放进度条时存在偏差的问题</li>\n<li>屏蔽播放器中没有歌曲时对进度条的点击</li>\n</ul>\n"
8+
},
59
{
610
"version": "0.3.2",
711
"desc": "<h3>新增</h3>\n<ul>\n<li>新增酷狗排行榜其他音质下载</li>\n</ul>\n"

src/renderer/components/core/Player.vue

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,15 +194,16 @@ export default {
194194
// console.log('code', this.audio.error.code)
195195
if (!this.musicInfo.songmid) return
196196
console.log('出错')
197+
this.stopPlay()
198+
this.sendProgressEvent(this.progress, 'error')
197199
if (this.audio.error.code !== 1 && this.retryNum < 3) { // 若音频URL无效则尝试刷新3次URL
198200
// console.log(this.retryNum)
199201
this.audioErrorTime = this.audio.currentTime // 记录出错的播放时间
200202
this.retryNum++
201203
this.setUrl(this.list[this.playIndex], true)
204+
this.status = 'URL过期,正在刷新URL...'
202205
return
203206
}
204-
this.stopPlay()
205-
this.sendProgressEvent(this.progress, 'error')
206207
207208
// let urls = this.player_info.targetSong.urls
208209
// if (urls && urls.some((url, index) => {

src/renderer/utils/music/kg/api-internal.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { httpFatch } from '../../request'
22
import { requestMsg } from '../../message'
3-
import { headers, timeout } from '../messoer'
3+
import { headers, timeout } from '../options'
44

55
const api_messoer = {
66
getMusicUrl(songInfo, type) {

src/renderer/utils/music/kw/api-internal.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { httpFatch } from '../../request'
22
import { requestMsg } from '../../message'
3-
import { headers, timeout } from '../messoer'
3+
import { headers, timeout } from '../options'
44

55
const api_messoer = {
66
getMusicUrl(songInfo, type) {
Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,18 @@
11
import { httpFatch } from '../../request'
2+
import { headers, timeout } from '../options'
23

34
const api_temp = {
45
getMusicUrl(songInfo, type) {
56
const requestObj = httpFatch(`http://45.32.53.128:3002/m/kw/u/${songInfo.songmid}/${type}`, {
67
method: 'get',
8+
headers,
9+
timeout,
710
})
811
requestObj.promise = requestObj.promise.then(({ body }) => {
912
return body.code === 0 ? Promise.resolve({ type, url: body.data }) : Promise.reject(new Error(body.msg))
1013
})
1114
return requestObj
1215
},
13-
getPic(songInfo) {
14-
const requestObj = httpFatch(`http://45.32.53.128:3002/m/kw/i/${songInfo.songmid}`, {
15-
method: 'get',
16-
})
17-
requestObj.promise = requestObj.promise.then(({ body }) => {
18-
return body.code === 0 ? Promise.resolve(body.data) : Promise.reject(new Error(body.msg))
19-
})
20-
return requestObj
21-
},
2216
}
2317

2418
export default api_temp

src/renderer/utils/music/kw/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import musicSearch from './musicSearch'
44
import { formatSinger } from './util'
55
import leaderboard from './leaderboard'
66
import lyric from './lyric'
7+
import pic from './pic'
78
import api_source from '../api-source'
89

910
const kw = {
@@ -91,7 +92,7 @@ const kw = {
9192
},
9293

9394
getPic(songInfo) {
94-
return api_source('kw').getPic(songInfo)
95+
return pic.getPic(songInfo)
9596
},
9697
}
9798

0 commit comments

Comments
 (0)