Skip to content

Commit

Permalink
更新到0.1.4版本
Browse files Browse the repository at this point in the history
  • Loading branch information
lyswhut committed Aug 18, 2019
1 parent ba8991a commit a580ced
Show file tree
Hide file tree
Showing 22 changed files with 306 additions and 161 deletions.
14 changes: 14 additions & 0 deletions CHANGELOG.md
Expand Up @@ -6,6 +6,20 @@ 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.1.4](https://github.com/lyswhut/lx-music-desktop/compare/v0.1.3...v0.1.4) - 2019-08-18

### 新增

- 新增音乐来源切换,可到设置页面-基本设置 look look !
- 为搜索结果列表添加多选功能。
P.S:暂时没想好多选后的操作按钮放哪...

### 优化

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

## [0.1.3](https://github.com/lyswhut/lx-music-desktop/compare/v0.1.2...v0.1.3) - 2019-08-17

### 新增
Expand Down
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "lx-music-desktop",
"version": "0.1.3",
"version": "0.1.4",
"description": "一个免费的音乐下载助手",
"main": "./dist/electron/main.js",
"scripts": {
Expand Down
10 changes: 9 additions & 1 deletion publish/changeLog.md
@@ -1,3 +1,11 @@
### 新增

- 新增音乐来源切换,可到设置页面-基本设置 look look !
- 为搜索结果列表添加多选功能。
P.S:暂时没想好多选后的操作按钮放哪...

### 优化

- 重构checkbox组件
- 重构与改进checkbox组件,使其支持不定选中状态
- 完善上一个版本的http请求封装并切换部分请求到该方法上
- 优化其他一些细节
8 changes: 6 additions & 2 deletions publish/version.json
@@ -1,7 +1,11 @@
{
"version": "0.1.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",
"version": "0.1.4",
"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",
"history": [
{
"version": "0.1.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"
},
{
"version": "0.1.2",
"desc": "<h3>修复</h3>\n<ul>\n<li>修复更新弹窗的内容显示问题</li>\n</ul>\n"
Expand Down
13 changes: 13 additions & 0 deletions src/renderer/App.vue
Expand Up @@ -28,6 +28,9 @@ export default {
data() {
return {
isProd: process.env.NODE_ENV === 'production',
globalObj: {
apiSource: 'messoer',
},
}
},
computed: {
Expand Down Expand Up @@ -59,12 +62,20 @@ export default {
},
deep: true,
},
'globalObj.apiSource'(n) {
if (n != this.setting.apiSource) {
this.setSetting(Object.assign({}, this.setting, {
apiSource: n,
}))
}
},
},
methods: {
...mapActions(['getVersionInfo']),
...mapMutations(['setNewVersion', 'setVersionVisible']),
...mapMutations('list', ['initDefaultList']),
...mapMutations('download', ['updateDownloadList']),
...mapMutations(['setSetting']),
init() {
if (this.isProd) {
body.addEventListener('mouseenter', this.dieableIgnoreMouseEvents)
Expand All @@ -80,6 +91,8 @@ export default {
})
this.initData()
this.globalObj.apiSource = this.setting.apiSource
window.globalObj = this.globalObj
},
enableIgnoreMouseEvents() {
win.setIgnoreMouseEvents(false)
Expand Down
24 changes: 17 additions & 7 deletions src/renderer/components/core/Player.vue
Expand Up @@ -90,6 +90,9 @@ export default {
// return 50
return this.nowPlayTime / this.maxPlayTime || 0
},
isAPITemp() {
return this.setting.apiSource == 'temp'
},
},
mounted() {
this.setProgessWidth()
Expand Down Expand Up @@ -249,7 +252,8 @@ export default {
},
handleNext() {
// if (this.list.listName === null) return
if (!this.list.length) return
const list = this.isAPITemp ? this.list.filter(s => s.source == 'kw') : this.list
if (!list.length) return
let index
switch (this.setting.player.togglePlayMethod) {
case 'listLoop':
Expand All @@ -267,14 +271,17 @@ export default {
if (index < 0) return
this.setPlayIndex(index)
},
hanldeListLoop() {
return this.playIndex === this.list.length - 1 ? 0 : this.playIndex + 1
hanldeListLoop(index = this.playIndex) {
index = index === this.list.length - 1 ? 0 : index + 1
return this.isAPITemp && this.list[index].source != 'kw' ? this.hanldeListLoop(index) : index
},
hanldeListNext() {
return this.playIndex === this.list.length - 1 ? -1 : this.playIndex + 1
hanldeListNext(index = this.playIndex) {
index = index === this.list.length - 1 ? -1 : index + 1
return this.isAPITemp && this.list[index].source != 'kw' ? this.hanldeListNext(index) : index
},
hanldeListRandom() {
return getRandom(0, this.list.length)
hanldeListRandom(index = this.playIndex) {
index = getRandom(0, this.list.length)
return this.isAPITemp && this.list[index].source != 'kw' ? this.hanldeListRandom(index) : index
},
startPlay() {
this.isPlay = true
Expand Down Expand Up @@ -314,6 +321,7 @@ export default {
setUrl(targetSong) {
let type = this.getPlayType(this.setting.player.highQuality, targetSong)
this.musicInfo.url = targetSong.typeUrl[type]
this.status = '歌曲链接获取中...'
let urlP = this.musicInfo.url
? Promise.resolve()
Expand All @@ -323,6 +331,8 @@ export default {
urlP.then(() => {
this.audio.src = this.musicInfo.url
}).catch(err => {
this.status = err.message
})
},
setImg(targetSong) {
Expand Down
29 changes: 22 additions & 7 deletions src/renderer/store/modules/player.js
Expand Up @@ -8,7 +8,9 @@ const state = {
changePlay: false,
}

let request
let urlRequest
let picRequest
let lrcRequest

// getters
const getters = {
Expand All @@ -21,19 +23,32 @@ const getters = {
// actions
const actions = {
getUrl({ commit, state }, { musicInfo, type }) {
if (request && request.cancelHttp) request.cancelHttp()
request = music[musicInfo.source].getMusicUrl(musicInfo, type)
return request.promise.then(result => {
if (urlRequest && urlRequest.cancelHttp) urlRequest.cancelHttp()
urlRequest = music[musicInfo.source].getMusicUrl(musicInfo, type)
return urlRequest.promise.then(result => {
commit('setUrl', { musicInfo, url: result.url, type })
}).finally(() => {
request = null
urlRequest = null
})
},
getPic({ commit, state }, musicInfo) {
return music[musicInfo.source].getPic(musicInfo).then(url => commit('getPic', { musicInfo, url }))
if (picRequest && picRequest.cancelHttp) picRequest.cancelHttp()
picRequest = music[musicInfo.source].getPic(musicInfo)
return picRequest.promise.then(url => {
console.log(url)
commit('getPic', { musicInfo, url })
}).finally(() => {
picRequest = null
})
},
getLrc({ commit, state }, musicInfo) {
return music[musicInfo.source].getLyric(musicInfo).then(lrc => commit('setLrc', { musicInfo, lrc }))
if (lrcRequest && lrcRequest.cancelHttp) lrcRequest.cancelHttp()
lrcRequest = music[musicInfo.source].getLyric(musicInfo)
return lrcRequest.promise.then(lrc => {
commit('setLrc', { musicInfo, lrc })
}).finally(() => {
lrcRequest = null
})
},
}

Expand Down
3 changes: 2 additions & 1 deletion src/renderer/utils/index.js
Expand Up @@ -157,7 +157,7 @@ export const isChildren = (parent, children) => {
}

export const updateSetting = setting => {
const defaultVersion = '1.0.1'
const defaultVersion = '1.0.2'
const defaultSetting = {
version: defaultVersion,
player: {
Expand All @@ -177,6 +177,7 @@ export const updateSetting = setting => {
},
themeId: 0,
sourceId: 'kw',
apiSource: 'messoer',
randomAnimate: true,
}
const overwriteSetting = {
Expand Down
28 changes: 28 additions & 0 deletions src/renderer/utils/music/api-source.js
@@ -0,0 +1,28 @@
import kw_api_messoer from './kw/api-messoer'
import kw_api_temp from './kw/api-temp'
import tx_api_messoer from './tx/api-messoer'

const apis = {
kw_api_messoer,
tx_api_messoer,
kw_api_temp,
}


const getAPI = source => {
switch (window.globalObj.apiSource) {
case 'messoer':
return apis[`${source}_api_messoer`]
case 'temp':
return apis[`${source}_api_temp`]
}
}

export default source => {
switch (source) {
case 'tx':
return getAPI('tx')
default:
return getAPI('kw')
}
}
26 changes: 26 additions & 0 deletions src/renderer/utils/music/kw/api-messoer.js
@@ -0,0 +1,26 @@
import { httpFatch } from '../../request'

const api_messoer = {
getMusicUrl(songInfo, type) {
const requestObj = httpFatch(`https://v1.itooi.cn/kuwo/url?id=${songInfo.songmid}&quality=${type.replace(/k$/, '')}&isRedirect=0`, {
method: 'get',
timeout: 5000,
})
requestObj.promise = requestObj.promise.then(({ body }) => {
return body.code === 200 ? Promise.resolve({ type, url: body.data }) : Promise.reject(new Error(body.msg))
})
return requestObj
},
getPic(songInfo) {
const requestObj = httpFatch(`https://v1.itooi.cn/kuwo/pic?id=${songInfo.songmid}&isRedirect=0`, {
method: 'get',
timeout: 5000,
})
requestObj.promise = requestObj.promise.then(({ body }) => {
return body.code === 200 ? Promise.resolve(body.data) : Promise.reject(new Error(body.msg))
})
return requestObj
},
}

export default api_messoer
33 changes: 33 additions & 0 deletions src/renderer/utils/music/kw/api-temp.js
@@ -0,0 +1,33 @@
import { httpFatch } from '../../request'

const api_temp = {
getMusicUrl(songInfo, type) {
const requestObj = httpFatch(`https://www.stsky.cn/api/temp/getMusicUrl.php?id=${songInfo.songmid}&type=${type}`, {
method: 'get',
})
requestObj.promise = requestObj.promise.then(({ body }) => {
return body.code === 0 ? Promise.resolve({ type, url: body.data }) : Promise.reject(new Error(body.msg))
}).catch(err => {
console.log(err)
if (err.message === 'socket hang up') return Promise.reject(new Error('接口挂了'))
if (err.code === 'ENOTFOUND') return Promise.reject(new Error('无法连接网络'))
return Promise.reject(err)
})
return requestObj
},
getPic(songInfo) {
const requestObj = httpFatch(`https://www.stsky.cn/api/temp/getPic.php?size=320&songmid=${songInfo.songmid}`, {
method: 'get',
})
requestObj.promise = requestObj.promise.then(({ body }) => {
return body.code === 0 ? Promise.resolve(body.data) : Promise.reject(new Error(body.msg))
}).catch(err => {
if (err.message === 'socket hang up') return Promise.reject(new Error('接口挂了'))
if (err.code === 'ENOTFOUND') return Promise.reject(new Error('无法连接网络'))
return Promise.reject(err)
})
return requestObj
},
}

export default api_temp
51 changes: 3 additions & 48 deletions src/renderer/utils/music/kw/index.js
Expand Up @@ -4,6 +4,7 @@ import musicSearch from './musicSearch'
import { formatSinger } from './util'
import leaderboard from './leaderboard'
import lyric from './lyric'
import api_source from '../api-source'

const kw = {
_musicInfoRequestObj: null,
Expand Down Expand Up @@ -52,36 +53,7 @@ const kw = {
},

getMusicUrl(songInfo, type) {
let requestObj
let cancelFn
const p = new Promise((resolve, reject) => {
cancelFn = reject
// requestObj = httpGet(`https://v1.itooi.cn/kuwo/url?id=${songInfo.songmid}&quality=${type.replace(/k$/, '')}&isRedirect=0`, (err, resp, body) => {
requestObj = httpGet(`https://www.stsky.cn/api/temp/getMusicUrl.php?id=${songInfo.songmid}&type=${type}`, (err, resp, body) => {
requestObj = null
cancelFn = null
if (err) {
if (err.message === 'socket hang up') return reject(new Error('接口挂了'))
const { promise, cancelHttp } = this.getMusicUrl(songInfo, type)
obj.cancelHttp = cancelHttp
return promise
}
// body.code === 200 ? resolve({ type, url: body.data }) : reject(new Error(body.msg))
body.code === 0 ? resolve({ type, url: body.data }) : reject(new Error(body.msg))
})
})
const obj = {
promise: p,
cancelHttp() {
console.log('cancel')
if (!requestObj) return
cancelHttp(requestObj)
cancelFn(new Error('取消http请求'))
requestObj = null
cancelFn = null
},
}
return obj
return api_source('kw').getMusicUrl(songInfo, type)
},

getMusicInfo(songInfo) {
Expand Down Expand Up @@ -119,24 +91,7 @@ const kw = {
},

getPic(songInfo) {
if (this._musicPicRequestObj != null) {
cancelHttp(this._musicPicRequestObj)
this._musicPicPromiseCancelFn(new Error('取消http请求'))
}
return new Promise((resolve, reject) => {
this._musicPicPromiseCancelFn = reject
// this._musicPicRequestObj = httpGet(`https://v1.itooi.cn/kuwo/pic?id=${songInfo.songmid}&isRedirect=0`, (err, resp, body) => {
this._musicPicRequestObj = httpGet(`https://www.stsky.cn/api/temp/getPic.php?size=320&songmid=${songInfo.songmid}`, (err, resp, body) => {
this._musicPicRequestObj = null
this._musicPicPromiseCancelFn = null
if (err) {
console.log(err)
reject(err)
}
// body.code === 200 ? resolve(body.data) : reject(new Error(body.msg))
body.code === 0 ? resolve(body.data) : reject(new Error(body.msg))
})
})
return api_source('kw').getPic(songInfo)
},
}

Expand Down

0 comments on commit a580ced

Please sign in to comment.