Skip to content

Commit a580ced

Browse files
committed
更新到0.1.4版本
1 parent ba8991a commit a580ced

22 files changed

Lines changed: 306 additions & 161 deletions

CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,20 @@ 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.1.4](https://github.com/lyswhut/lx-music-desktop/compare/v0.1.3...v0.1.4) - 2019-08-18
10+
11+
### 新增
12+
13+
- 新增音乐来源切换,可到设置页面-基本设置 look look !
14+
- 为搜索结果列表添加多选功能。
15+
P.S:暂时没想好多选后的操作按钮放哪...
16+
17+
### 优化
18+
19+
- 重构与改进checkbox组件,使其支持不定选中状态
20+
- 完善上一个版本的http请求封装并切换部分请求到该方法上
21+
- 优化其他一些细节
22+
923
## [0.1.3](https://github.com/lyswhut/lx-music-desktop/compare/v0.1.2...v0.1.3) - 2019-08-17
1024

1125
### 新增

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.1.3",
3+
"version": "0.1.4",
44
"description": "一个免费的音乐下载助手",
55
"main": "./dist/electron/main.js",
66
"scripts": {

publish/changeLog.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
### 新增
2+
3+
- 新增音乐来源切换,可到设置页面-基本设置 look look !
4+
- 为搜索结果列表添加多选功能。
5+
P.S:暂时没想好多选后的操作按钮放哪...
6+
17
### 优化
28

3-
- 重构checkbox组件
9+
- 重构与改进checkbox组件,使其支持不定选中状态
10+
- 完善上一个版本的http请求封装并切换部分请求到该方法上
11+
- 优化其他一些细节

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.1.3",
3-
"desc": "<h3>新增</h3>\n<ul>\n<li>新增win32应用构建</li>\n</ul>\n<h3>修复</h3>\n<ul>\n<li>修复安装包许可协议乱码问题</li>\n<li><strong>messoer 提供的接口已挂</strong>,暂时切换到临时接口!</li>\n</ul>\n<h3>移除</h3>\n<ul>\n<li>由于messoer接口无法使用,QQ音乐排行榜直接播放/下载功能暂时关闭</li>\n</ul>\n",
2+
"version": "0.1.4",
3+
"desc": "<h3>新增</h3>\n<ul>\n<li>新增音乐来源切换,可到设置页面-基本设置 look look !</li>\n<li>为搜索结果列表添加多选功能。<br>\nP.S:暂时没想好多选后的操作按钮放哪…</li>\n</ul>\n<h3>优化</h3>\n<ul>\n<li>重构与改进checkbox组件,使其支持不定选中状态</li>\n<li>完善上一个版本的http请求封装并切换部分请求到该方法上</li>\n<li>优化其他一些细节</li>\n</ul>\n",
44
"history": [
5+
{
6+
"version": "0.1.3",
7+
"desc": "<h3>新增</h3>\n<ul>\n<li>新增win32应用构建</li>\n</ul>\n<h3>修复</h3>\n<ul>\n<li>修复安装包许可协议乱码问题</li>\n<li><strong>messoer 提供的接口已挂</strong>,暂时切换到临时接口!</li>\n</ul>\n<h3>移除</h3>\n<ul>\n<li>由于messoer接口无法使用,QQ音乐排行榜直接播放/下载功能暂时关闭</li>\n</ul>\n"
8+
},
59
{
610
"version": "0.1.2",
711
"desc": "<h3>修复</h3>\n<ul>\n<li>修复更新弹窗的内容显示问题</li>\n</ul>\n"

src/renderer/App.vue

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ export default {
2828
data() {
2929
return {
3030
isProd: process.env.NODE_ENV === 'production',
31+
globalObj: {
32+
apiSource: 'messoer',
33+
},
3134
}
3235
},
3336
computed: {
@@ -59,12 +62,20 @@ export default {
5962
},
6063
deep: true,
6164
},
65+
'globalObj.apiSource'(n) {
66+
if (n != this.setting.apiSource) {
67+
this.setSetting(Object.assign({}, this.setting, {
68+
apiSource: n,
69+
}))
70+
}
71+
},
6272
},
6373
methods: {
6474
...mapActions(['getVersionInfo']),
6575
...mapMutations(['setNewVersion', 'setVersionVisible']),
6676
...mapMutations('list', ['initDefaultList']),
6777
...mapMutations('download', ['updateDownloadList']),
78+
...mapMutations(['setSetting']),
6879
init() {
6980
if (this.isProd) {
7081
body.addEventListener('mouseenter', this.dieableIgnoreMouseEvents)
@@ -80,6 +91,8 @@ export default {
8091
})
8192
8293
this.initData()
94+
this.globalObj.apiSource = this.setting.apiSource
95+
window.globalObj = this.globalObj
8396
},
8497
enableIgnoreMouseEvents() {
8598
win.setIgnoreMouseEvents(false)

src/renderer/components/core/Player.vue

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,9 @@ export default {
9090
// return 50
9191
return this.nowPlayTime / this.maxPlayTime || 0
9292
},
93+
isAPITemp() {
94+
return this.setting.apiSource == 'temp'
95+
},
9396
},
9497
mounted() {
9598
this.setProgessWidth()
@@ -249,7 +252,8 @@ export default {
249252
},
250253
handleNext() {
251254
// if (this.list.listName === null) return
252-
if (!this.list.length) return
255+
const list = this.isAPITemp ? this.list.filter(s => s.source == 'kw') : this.list
256+
if (!list.length) return
253257
let index
254258
switch (this.setting.player.togglePlayMethod) {
255259
case 'listLoop':
@@ -267,14 +271,17 @@ export default {
267271
if (index < 0) return
268272
this.setPlayIndex(index)
269273
},
270-
hanldeListLoop() {
271-
return this.playIndex === this.list.length - 1 ? 0 : this.playIndex + 1
274+
hanldeListLoop(index = this.playIndex) {
275+
index = index === this.list.length - 1 ? 0 : index + 1
276+
return this.isAPITemp && this.list[index].source != 'kw' ? this.hanldeListLoop(index) : index
272277
},
273-
hanldeListNext() {
274-
return this.playIndex === this.list.length - 1 ? -1 : this.playIndex + 1
278+
hanldeListNext(index = this.playIndex) {
279+
index = index === this.list.length - 1 ? -1 : index + 1
280+
return this.isAPITemp && this.list[index].source != 'kw' ? this.hanldeListNext(index) : index
275281
},
276-
hanldeListRandom() {
277-
return getRandom(0, this.list.length)
282+
hanldeListRandom(index = this.playIndex) {
283+
index = getRandom(0, this.list.length)
284+
return this.isAPITemp && this.list[index].source != 'kw' ? this.hanldeListRandom(index) : index
278285
},
279286
startPlay() {
280287
this.isPlay = true
@@ -314,6 +321,7 @@ export default {
314321
setUrl(targetSong) {
315322
let type = this.getPlayType(this.setting.player.highQuality, targetSong)
316323
this.musicInfo.url = targetSong.typeUrl[type]
324+
this.status = '歌曲链接获取中...'
317325
318326
let urlP = this.musicInfo.url
319327
? Promise.resolve()
@@ -323,6 +331,8 @@ export default {
323331
324332
urlP.then(() => {
325333
this.audio.src = this.musicInfo.url
334+
}).catch(err => {
335+
this.status = err.message
326336
})
327337
},
328338
setImg(targetSong) {

src/renderer/store/modules/player.js

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ const state = {
88
changePlay: false,
99
}
1010

11-
let request
11+
let urlRequest
12+
let picRequest
13+
let lrcRequest
1214

1315
// getters
1416
const getters = {
@@ -21,19 +23,32 @@ const getters = {
2123
// actions
2224
const actions = {
2325
getUrl({ commit, state }, { musicInfo, type }) {
24-
if (request && request.cancelHttp) request.cancelHttp()
25-
request = music[musicInfo.source].getMusicUrl(musicInfo, type)
26-
return request.promise.then(result => {
26+
if (urlRequest && urlRequest.cancelHttp) urlRequest.cancelHttp()
27+
urlRequest = music[musicInfo.source].getMusicUrl(musicInfo, type)
28+
return urlRequest.promise.then(result => {
2729
commit('setUrl', { musicInfo, url: result.url, type })
2830
}).finally(() => {
29-
request = null
31+
urlRequest = null
3032
})
3133
},
3234
getPic({ commit, state }, musicInfo) {
33-
return music[musicInfo.source].getPic(musicInfo).then(url => commit('getPic', { musicInfo, url }))
35+
if (picRequest && picRequest.cancelHttp) picRequest.cancelHttp()
36+
picRequest = music[musicInfo.source].getPic(musicInfo)
37+
return picRequest.promise.then(url => {
38+
console.log(url)
39+
commit('getPic', { musicInfo, url })
40+
}).finally(() => {
41+
picRequest = null
42+
})
3443
},
3544
getLrc({ commit, state }, musicInfo) {
36-
return music[musicInfo.source].getLyric(musicInfo).then(lrc => commit('setLrc', { musicInfo, lrc }))
45+
if (lrcRequest && lrcRequest.cancelHttp) lrcRequest.cancelHttp()
46+
lrcRequest = music[musicInfo.source].getLyric(musicInfo)
47+
return lrcRequest.promise.then(lrc => {
48+
commit('setLrc', { musicInfo, lrc })
49+
}).finally(() => {
50+
lrcRequest = null
51+
})
3752
},
3853
}
3954

src/renderer/utils/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ export const isChildren = (parent, children) => {
157157
}
158158

159159
export const updateSetting = setting => {
160-
const defaultVersion = '1.0.1'
160+
const defaultVersion = '1.0.2'
161161
const defaultSetting = {
162162
version: defaultVersion,
163163
player: {
@@ -177,6 +177,7 @@ export const updateSetting = setting => {
177177
},
178178
themeId: 0,
179179
sourceId: 'kw',
180+
apiSource: 'messoer',
180181
randomAnimate: true,
181182
}
182183
const overwriteSetting = {
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import kw_api_messoer from './kw/api-messoer'
2+
import kw_api_temp from './kw/api-temp'
3+
import tx_api_messoer from './tx/api-messoer'
4+
5+
const apis = {
6+
kw_api_messoer,
7+
tx_api_messoer,
8+
kw_api_temp,
9+
}
10+
11+
12+
const getAPI = source => {
13+
switch (window.globalObj.apiSource) {
14+
case 'messoer':
15+
return apis[`${source}_api_messoer`]
16+
case 'temp':
17+
return apis[`${source}_api_temp`]
18+
}
19+
}
20+
21+
export default source => {
22+
switch (source) {
23+
case 'tx':
24+
return getAPI('tx')
25+
default:
26+
return getAPI('kw')
27+
}
28+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { httpFatch } from '../../request'
2+
3+
const api_messoer = {
4+
getMusicUrl(songInfo, type) {
5+
const requestObj = httpFatch(`https://v1.itooi.cn/kuwo/url?id=${songInfo.songmid}&quality=${type.replace(/k$/, '')}&isRedirect=0`, {
6+
method: 'get',
7+
timeout: 5000,
8+
})
9+
requestObj.promise = requestObj.promise.then(({ body }) => {
10+
return body.code === 200 ? Promise.resolve({ type, url: body.data }) : Promise.reject(new Error(body.msg))
11+
})
12+
return requestObj
13+
},
14+
getPic(songInfo) {
15+
const requestObj = httpFatch(`https://v1.itooi.cn/kuwo/pic?id=${songInfo.songmid}&isRedirect=0`, {
16+
method: 'get',
17+
timeout: 5000,
18+
})
19+
requestObj.promise = requestObj.promise.then(({ body }) => {
20+
return body.code === 200 ? Promise.resolve(body.data) : Promise.reject(new Error(body.msg))
21+
})
22+
return requestObj
23+
},
24+
}
25+
26+
export default api_messoer

0 commit comments

Comments
 (0)