新增列表多选操作功能

This commit is contained in:
lyswhut
2019-08-19 18:19:39 +08:00
parent 8817318a53
commit 601e1a67a1
26 changed files with 750 additions and 192 deletions
+1 -2
View File
@@ -45,9 +45,8 @@ export default ({
onEnd()
debugDownload && console.log('Download Completed')
}).on('error', err => {
if (err.message === 'socket hang up') return
onError(err)
dl.resume()
console.log('Download failed, Attempting Retry')
debugDownload && console.error('Something happend', err)
}).on('stateChanged', state => {
onStateChanged(state)
+7 -1
View File
@@ -156,8 +156,12 @@ export const isChildren = (parent, children) => {
return children.parentNode ? children.parentNode === parent ? true : isChildren(parent, children.parentNode) : false
}
/**
* 升级设置
* @param {*} setting
*/
export const updateSetting = setting => {
const defaultVersion = '1.0.2'
const defaultVersion = '1.0.3'
const defaultSetting = {
version: defaultVersion,
player: {
@@ -170,6 +174,7 @@ export const updateSetting = setting => {
download: {
savePath: path.join(os.homedir(), 'Desktop'),
fileName: '歌名 - 歌手',
maxDownloadNum: 3,
},
leaderboard: {
source: 'kw',
@@ -203,3 +208,4 @@ export const updateSetting = setting => {
export const openUrl = url => {
shell.openExternal(url)
}
+6
View File
@@ -0,0 +1,6 @@
export const requestMsg = {
fail: '请求异常😮,可以多试几次,若还是不行就换一首吧。。。',
unachievable: '哦No😱...接口无法访问了!已帮你切换到临时接口,重试下看能不能播放吧~',
notConnectNetwork: '无法连接网络',
cancelRequest: '取消http请求',
}
+3 -2
View File
@@ -1,4 +1,5 @@
import { httpFatch } from '../../request'
import { requestMsg } from '../../message'
const api_messoer = {
getMusicUrl(songInfo, type) {
@@ -7,7 +8,7 @@ const api_messoer = {
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 body.code === 200 ? Promise.resolve({ type, url: body.data }) : Promise.reject(new Error(requestMsg.fail))
})
return requestObj
},
@@ -17,7 +18,7 @@ const api_messoer = {
timeout: 5000,
})
requestObj.promise = requestObj.promise.then(({ body }) => {
return body.code === 200 ? Promise.resolve(body.data) : Promise.reject(new Error(body.msg))
return body.code === 200 ? Promise.resolve(body.data) : Promise.reject(new Error(requestMsg.fail))
})
return requestObj
},
-9
View File
@@ -7,11 +7,6 @@ const api_temp = {
})
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
},
@@ -21,10 +16,6 @@ const api_temp = {
})
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
},
+2 -1
View File
@@ -1,4 +1,5 @@
import { httpFatch } from '../../request'
import { requestMsg } from '../../message'
const api_messoer = {
getMusicUrl(songInfo, type) {
@@ -7,7 +8,7 @@ const api_messoer = {
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 body.code === 200 ? Promise.resolve({ type, url: body.data }) : Promise.reject(new Error(requestMsg.fail))
})
return requestObj
},
+12
View File
@@ -0,0 +1,12 @@
/**
* 获取音乐音质
* @param {*} info
* @param {*} type
*/
const types = ['flac', 'ape', '320k', '192k', '128k']
export const getMusicType = (info, type) => {
const rangeType = types.slice(types.indexOf(type))
for (const type of rangeType) {
if (info._types[type]) return type
}
}
+5 -4
View File
@@ -1,6 +1,7 @@
import request from 'request'
// import progress from 'request-progress'
import { debugRequest } from './env'
import { requestMsg } from './message'
// import fs from 'fs'
const headers = {
@@ -9,7 +10,7 @@ const headers = {
const fatchData = (url, method, options, callback) => {
// console.log(url, options)
// console.log('---start---', url)
console.log('---start---', url)
return request(url, {
method,
headers: Object.assign({}, headers, options.headers || {}),
@@ -60,7 +61,7 @@ const buildHttpPromose = (url, options) => {
console.log('cancel')
if (!requestObj) return
cancelHttp(requestObj)
cancelFn(new Error('取消http请求'))
cancelFn(new Error(requestMsg.cancelRequest))
requestObj = null
cancelFn = null
},
@@ -84,9 +85,9 @@ export const httpFatch = (url, options = { method: 'get' }) => {
}
if (err.message === 'socket hang up') {
window.globalObj.apiSource = 'temp'
return Promise.reject(new Error('哦No😱...接口无法访问了!已帮你切换到临时接口,重试下看能不能播放吧~'))
return Promise.reject(new Error(requestMsg.unachievable))
}
if (err.code === 'ENOTFOUND') return Promise.reject(new Error('无法连接网络'))
if (err.code === 'ENOTFOUND') return Promise.reject(new Error(requestMsg.notConnectNetwork))
return Promise.reject(err)
})
return requestObj