Skip to content

Commit

Permalink
优化请求,修复加载bug
Browse files Browse the repository at this point in the history
  • Loading branch information
lyswhut committed Aug 29, 2019
1 parent aa973ea commit 1786376
Show file tree
Hide file tree
Showing 16 changed files with 48 additions and 27 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,5 @@ dist
publish/assets

publish/utils/githubToken.js

src/**/*-internal.js
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,16 @@ Project versioning adheres to [Semantic Versioning](http://semver.org/).
Commit convention is based on [Conventional Commits](http://conventionalcommits.org).
Change log format is based on [Keep a Changelog](http://keepachangelog.com/).

## [0.3.4](https://github.com/lyswhut/lx-music-desktop/compare/v0.3.3...v0.3.4) - 2019-08-29

### 优化

- 减少接口不稳定带来的影响,适当增加请求等待时间

### 修复

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

## [0.3.3](https://github.com/lyswhut/lx-music-desktop/compare/v0.3.2...v0.3.3) - 2019-08-29

### 修复
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "lx-music-desktop",
"version": "0.3.3",
"version": "0.3.4",
"description": "一个免费的音乐下载助手",
"main": "./dist/electron/main.js",
"productName": "lx-music-desktop",
Expand Down
10 changes: 5 additions & 5 deletions publish/changeLog.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
### 修复
### 优化

- 减少接口不稳定带来的影响,适当增加请求等待时间

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

- 修复播放过程中URL过期不会刷新URL的问题
8 changes: 6 additions & 2 deletions publish/version.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
{
"version": "0.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",
"version": "0.3.4",
"desc": "<h3>优化</h3>\n<ul>\n<li>减少接口不稳定带来的影响,适当增加请求等待时间</li>\n</ul>\n<h3>修复</h3>\n<ul>\n<li>修复播放过程中URL过期不会刷新URL的问题</li>\n</ul>\n",
"history": [
{
"version": "0.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"
},
{
"version": "0.3.2",
"desc": "<h3>新增</h3>\n<ul>\n<li>新增酷狗排行榜其他音质下载</li>\n</ul>\n"
Expand Down
5 changes: 3 additions & 2 deletions src/renderer/components/core/Player.vue
Original file line number Diff line number Diff line change
Expand Up @@ -194,15 +194,16 @@ export default {
// console.log('code', this.audio.error.code)
if (!this.musicInfo.songmid) return
console.log('出错')
this.stopPlay()
this.sendProgressEvent(this.progress, 'error')
if (this.audio.error.code !== 1 && this.retryNum < 3) { // 若音频URL无效则尝试刷新3次URL
// console.log(this.retryNum)
this.audioErrorTime = this.audio.currentTime // 记录出错的播放时间
this.retryNum++
this.setUrl(this.list[this.playIndex], true)
this.status = 'URL过期,正在刷新URL...'
return
}
this.stopPlay()
this.sendProgressEvent(this.progress, 'error')
// let urls = this.player_info.targetSong.urls
// if (urls && urls.some((url, index) => {
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/utils/music/kg/api-internal.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { httpFatch } from '../../request'
import { requestMsg } from '../../message'
import { headers, timeout } from '../messoer'
import { headers, timeout } from '../options'

const api_messoer = {
getMusicUrl(songInfo, type) {
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/utils/music/kw/api-internal.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { httpFatch } from '../../request'
import { requestMsg } from '../../message'
import { headers, timeout } from '../messoer'
import { headers, timeout } from '../options'

const api_messoer = {
getMusicUrl(songInfo, type) {
Expand Down
12 changes: 3 additions & 9 deletions src/renderer/utils/music/kw/api-temp.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,18 @@
import { httpFatch } from '../../request'
import { headers, timeout } from '../options'

const api_temp = {
getMusicUrl(songInfo, type) {
const requestObj = httpFatch(`http://45.32.53.128:3002/m/kw/u/${songInfo.songmid}/${type}`, {
method: 'get',
headers,
timeout,
})
requestObj.promise = requestObj.promise.then(({ body }) => {
return body.code === 0 ? Promise.resolve({ type, url: body.data }) : Promise.reject(new Error(body.msg))
})
return requestObj
},
getPic(songInfo) {
const requestObj = httpFatch(`http://45.32.53.128:3002/m/kw/i/${songInfo.songmid}`, {
method: 'get',
})
requestObj.promise = requestObj.promise.then(({ body }) => {
return body.code === 0 ? Promise.resolve(body.data) : Promise.reject(new Error(body.msg))
})
return requestObj
},
}

export default api_temp
3 changes: 2 additions & 1 deletion src/renderer/utils/music/kw/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import musicSearch from './musicSearch'
import { formatSinger } from './util'
import leaderboard from './leaderboard'
import lyric from './lyric'
import pic from './pic'
import api_source from '../api-source'

const kw = {
Expand Down Expand Up @@ -91,7 +92,7 @@ const kw = {
},

getPic(songInfo) {
return api_source('kw').getPic(songInfo)
return pic.getPic(songInfo)
},
}

Expand Down
9 changes: 9 additions & 0 deletions src/renderer/utils/music/kw/pic.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { httpFatch } from '../../request'

export default {
getPic({ songmid }) {
const requestObj = httpFatch(`http://artistpicserver.kuwo.cn/pic.web?corp=kuwo&type=rid_pic&pictype=500&size=500&rid=${songmid}`)
requestObj.promise = requestObj.promise.then(({ body }) => body)
return requestObj
},
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ export const headers = {
}


export const timeout = 10000
export const timeout = 15000
2 changes: 1 addition & 1 deletion src/renderer/utils/music/tx/api-internal.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { httpFatch } from '../../request'
import { requestMsg } from '../../message'
import { headers, timeout } from '../messoer'
import { headers, timeout } from '../options'

const api_messoer = {
getMusicUrl(songInfo, type) {
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/utils/music/wy/api-internal.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { httpFatch } from '../../request'
import { requestMsg } from '../../message'
import { headers, timeout } from '../messoer'
import { headers, timeout } from '../options'

const api_messoer = {
getMusicUrl(songInfo, type) {
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/utils/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import request from 'request'
// import progress from 'request-progress'
import { debugRequest } from './env'
import { requestMsg } from './message'
import { bHh } from './music/messoer'
import { bHh } from './music/options'
// import fs from 'fs'

const headers = {
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/views/Setting.vue
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ export default {
// },
{
id: 'temp',
label: '临时接口(软件的某些功能将不可用,但可下载无损等音质',
label: '临时接口(软件的某些功能不可用,该接口访问速度较慢,请耐心等待',
disabled: false,
},
],
Expand Down

0 comments on commit 1786376

Please sign in to comment.