新增下载管理的任务状态分类
parent
1823598a8b
commit
88c62e01ad
|
@ -1,6 +1,7 @@
|
||||||
### 新增
|
### 新增
|
||||||
|
|
||||||
- 新增歌曲缓冲定时器,尝试用于解决网络正常但是歌曲缓冲过久的问题
|
- 新增歌曲缓冲定时器,尝试用于解决网络正常但是歌曲缓冲过久的问题
|
||||||
|
- 新增下载管理的任务状态分类
|
||||||
|
|
||||||
### 优化
|
### 优化
|
||||||
|
|
||||||
|
|
|
@ -210,7 +210,7 @@ export default {
|
||||||
return result
|
return result
|
||||||
}).then(result => {
|
}).then(result => {
|
||||||
if (result.version === this.version.version) return
|
if (result.version === this.version.version) return
|
||||||
console.log(this.version)
|
// console.log(this.version)
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
this.setVersionModalVisible({ isShow: true })
|
this.setVersionModalVisible({ isShow: true })
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
<template lang="pug">
|
<template lang="pug">
|
||||||
div(:class="$style.download")
|
div(:class="$style.download")
|
||||||
//- transition
|
//- transition
|
||||||
|
div(:class="$style.header")
|
||||||
|
material-tab(:class="$style.tab" :list="tabs" align="left" item-key="id" item-name="name" v-model="tabId")
|
||||||
div(:class="$style.content" v-if="list.length")
|
div(:class="$style.content" v-if="list.length")
|
||||||
div(:class="$style.thead")
|
div(:class="$style.thead")
|
||||||
table
|
table
|
||||||
|
@ -17,7 +19,7 @@ div(:class="$style.download")
|
||||||
div.scroll(v-if="list.length" :class="$style.tbody")
|
div.scroll(v-if="list.length" :class="$style.tbody")
|
||||||
table
|
table
|
||||||
tbody
|
tbody
|
||||||
tr(v-for='(item, index) in list' :key='item.key' @click="handleDoubleClick(index)" :class="isPlayList && playIndex === index ? $style.active : ''")
|
tr(v-for='(item, index) in showList' :key='item.key' @click="handleDoubleClick(index)" :class="playListIndex === index ? $style.active : ''")
|
||||||
td.nobreak.center(style="width: 37px;" @click.stop)
|
td.nobreak.center(style="width: 37px;" @click.stop)
|
||||||
material-checkbox(:id="index.toString()" v-model="selectdData" :value="item")
|
material-checkbox(:id="index.toString()" v-model="selectdData" :value="item")
|
||||||
td.break(style="width: 28%;") {{item.musicInfo.name}} - {{item.musicInfo.singer}}
|
td.break(style="width: 28%;") {{item.musicInfo.name}} - {{item.musicInfo.singer}}
|
||||||
|
@ -46,6 +48,29 @@ export default {
|
||||||
isIndeterminate: false,
|
isIndeterminate: false,
|
||||||
isShowEditBtn: false,
|
isShowEditBtn: false,
|
||||||
isShowDownloadMultiple: false,
|
isShowDownloadMultiple: false,
|
||||||
|
tabs: [
|
||||||
|
{
|
||||||
|
name: '全部任务',
|
||||||
|
id: 'all',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: '正在下载',
|
||||||
|
id: 'runing',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: '已暂停',
|
||||||
|
id: 'paused',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: '出错',
|
||||||
|
id: 'error',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: '下载完成',
|
||||||
|
id: 'finished',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
tabId: 'all',
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
@ -54,6 +79,25 @@ export default {
|
||||||
isPlayList() {
|
isPlayList() {
|
||||||
return this.listId == 'download'
|
return this.listId == 'download'
|
||||||
},
|
},
|
||||||
|
playListIndex() {
|
||||||
|
if (this.listId != 'download') return
|
||||||
|
let path = this.list[this.playIndex].filePath
|
||||||
|
return this.showList.findIndex(i => i.filePath == path)
|
||||||
|
},
|
||||||
|
showList() {
|
||||||
|
switch (this.tabId) {
|
||||||
|
case 'runing':
|
||||||
|
return this.list.filter(i => i.status == this.downloadStatus.RUN || i.status == this.downloadStatus.WAITING)
|
||||||
|
case 'paused':
|
||||||
|
return this.list.filter(i => i.status == this.downloadStatus.PAUSE)
|
||||||
|
case 'error':
|
||||||
|
return this.list.filter(i => i.status == this.downloadStatus.ERROR)
|
||||||
|
case 'finished':
|
||||||
|
return this.list.filter(i => i.status == this.downloadStatus.COMPLETED)
|
||||||
|
default:
|
||||||
|
return this.list
|
||||||
|
}
|
||||||
|
},
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
selectdData(n) {
|
selectdData(n) {
|
||||||
|
@ -76,14 +120,14 @@ export default {
|
||||||
...mapMutations('player', ['setList']),
|
...mapMutations('player', ['setList']),
|
||||||
...mapMutations('download', ['pauseTask']),
|
...mapMutations('download', ['pauseTask']),
|
||||||
handlePauseTask(index) {
|
handlePauseTask(index) {
|
||||||
let info = this.list[index]
|
let info = this.showList[index]
|
||||||
let dl = this.dls[info.key]
|
let dl = this.dls[info.key]
|
||||||
dl ? dl.pause() : this.pauseTask(info)
|
dl ? dl.pause() : this.pauseTask(info)
|
||||||
console.log('pause')
|
console.log('pause')
|
||||||
},
|
},
|
||||||
handleStartTask(index) {
|
handleStartTask(index) {
|
||||||
console.log('start')
|
console.log('start')
|
||||||
let info = this.list[index]
|
let info = this.showList[index]
|
||||||
let dl = this.dls[info.key]
|
let dl = this.dls[info.key]
|
||||||
dl ? dl.resume() : this.startTask(info)
|
dl ? dl.resume() : this.startTask(info)
|
||||||
},
|
},
|
||||||
|
@ -101,7 +145,7 @@ export default {
|
||||||
this.clickIndex = -1
|
this.clickIndex = -1
|
||||||
},
|
},
|
||||||
handleClick(index) {
|
handleClick(index) {
|
||||||
let info = this.list[index]
|
let info = this.showList[index]
|
||||||
if (info.isComplate) {
|
if (info.isComplate) {
|
||||||
this.handlePlay(index)
|
this.handlePlay(index)
|
||||||
} else if (info.status === this.downloadStatus.RUN) {
|
} else if (info.status === this.downloadStatus.RUN) {
|
||||||
|
@ -111,8 +155,9 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
handlePlay(index) {
|
handlePlay(index) {
|
||||||
if (!checkPath(this.list[index].filePath)) return
|
if (!checkPath(this.showList[index].filePath)) return
|
||||||
this.setList({ list: this.list, listId: 'download', index })
|
let path = this.showList[index].filePath
|
||||||
|
this.setList({ list: this.list, listId: 'download', index: this.list.findIndex(i => i.filePath === path) })
|
||||||
},
|
},
|
||||||
handleListBtnClick(info) {
|
handleListBtnClick(info) {
|
||||||
switch (info.action) {
|
switch (info.action) {
|
||||||
|
@ -134,7 +179,7 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
handleSelectAllData(isSelect) {
|
handleSelectAllData(isSelect) {
|
||||||
this.selectdData = isSelect ? [...this.list] : []
|
this.selectdData = isSelect ? [...this.showList] : []
|
||||||
},
|
},
|
||||||
resetSelect() {
|
resetSelect() {
|
||||||
this.isSelectAll = false
|
this.isSelectAll = false
|
||||||
|
@ -145,7 +190,7 @@ export default {
|
||||||
case 'start':
|
case 'start':
|
||||||
this.selectdData.forEach(item => {
|
this.selectdData.forEach(item => {
|
||||||
if (item.isComplate || item.status == this.downloadStatus.RUN) return
|
if (item.isComplate || item.status == this.downloadStatus.RUN) return
|
||||||
let index = this.list.indexOf(item)
|
let index = this.showList.indexOf(item)
|
||||||
if (index < 0) return
|
if (index < 0) return
|
||||||
this.handleStartTask(index)
|
this.handleStartTask(index)
|
||||||
})
|
})
|
||||||
|
@ -155,13 +200,13 @@ export default {
|
||||||
this.selectdData.forEach(item => {
|
this.selectdData.forEach(item => {
|
||||||
if (item.isComplate || item.status == this.downloadStatus.PAUSE) return
|
if (item.isComplate || item.status == this.downloadStatus.PAUSE) return
|
||||||
if (item.status == this.downloadStatus.RUN) return runs.push(item)
|
if (item.status == this.downloadStatus.RUN) return runs.push(item)
|
||||||
let index = this.list.indexOf(item)
|
let index = this.showList.indexOf(item)
|
||||||
if (index < 0) return
|
if (index < 0) return
|
||||||
this.handlePauseTask(index)
|
this.handlePauseTask(index)
|
||||||
})
|
})
|
||||||
runs.forEach(item => {
|
runs.forEach(item => {
|
||||||
if (item.isComplate || item.status == this.downloadStatus.PAUSE) return
|
if (item.isComplate || item.status == this.downloadStatus.PAUSE) return
|
||||||
let index = this.list.indexOf(item)
|
let index = this.showList.indexOf(item)
|
||||||
if (index < 0) return
|
if (index < 0) return
|
||||||
this.handlePauseTask(index)
|
this.handlePauseTask(index)
|
||||||
})
|
})
|
||||||
|
@ -174,7 +219,7 @@ export default {
|
||||||
this.resetSelect()
|
this.resetSelect()
|
||||||
},
|
},
|
||||||
handleOpenFolder(index) {
|
handleOpenFolder(index) {
|
||||||
let path = this.list[index].filePath
|
let path = this.showList[index].filePath
|
||||||
if (!checkPath(path)) return
|
if (!checkPath(path)) return
|
||||||
openDirInExplorer(path)
|
openDirInExplorer(path)
|
||||||
},
|
},
|
||||||
|
@ -188,16 +233,23 @@ export default {
|
||||||
.download {
|
.download {
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
|
display: flex;
|
||||||
|
flex-flow: column nowrap;
|
||||||
// .noItem {
|
// .noItem {
|
||||||
|
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
.header {
|
||||||
|
flex: none;
|
||||||
|
}
|
||||||
|
|
||||||
.content {
|
.content {
|
||||||
height: 100%;
|
height: 100%;
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-flow: column nowrap;
|
flex-flow: column nowrap;
|
||||||
|
flex: auto;
|
||||||
|
overflow: hidden;
|
||||||
// table {
|
// table {
|
||||||
// position: relative;
|
// position: relative;
|
||||||
// thead {
|
// thead {
|
||||||
|
|
Loading…
Reference in New Issue