Skip to content

Commit

Permalink
fix chunk download bug
Browse files Browse the repository at this point in the history
  • Loading branch information
monkeyWie committed Sep 19, 2018
1 parent dedb804 commit 33f7e3a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 23 deletions.
40 changes: 17 additions & 23 deletions front/src/components/Table/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
<Checkbox v-model="all"
@on-change="setAll"></Checkbox>
</div>
<div class="th">{{ $t("tasks.fileName") }}</div>
<div class="th">{{ $t("tasks.fileSize") }}</div>
<div class="th">{{ $t("tasks.taskProgress") }}</div>
<div class="th">{{ $t("tasks.downloadSpeed") }}</div>
<div class="th">{{ $t("tasks.status") }}</div>
<div class="th">{{ $t("tasks.operate") }}</div>
<div class="th">{{ $t("tasks.fileName") }}</div>
<div class="th">{{ $t("tasks.fileSize") }}</div>
<div class="th">{{ $t("tasks.taskProgress") }}</div>
<div class="th">{{ $t("tasks.downloadSpeed") }}</div>
<div class="th">{{ $t("tasks.status") }}</div>
<div class="th">{{ $t("tasks.operate") }}</div>
</div>
</div>
</div>
Expand All @@ -31,7 +31,7 @@
@on-change="toggleAll"></Checkbox>
</div>
<div class="td">{{ task.response.fileName }}</div>
<div class="td">{{ $numeral(task.response.totalSize).format('0.00b') }}</div>
<div class="td">{{ task.response.totalSize?$numeral(task.response.totalSize).format('0.00b'):$t('tasks.unknowLeft') }}</div>
<div class="td">{{ calcProgress(task) }}</div>
<div class="td">{{ $numeral(task.info.speed).format('0.00b') }}/S</div>
<div class="td">{{ calcStatus(task) }}</div>
Expand All @@ -40,17 +40,16 @@
class="action-icon"
type="ios-pause"
@click="$emit('on-pause', task)"></Icon>
<Icon v-else-if="task.info.status === 4"
class="action-icon"
type="ios-folder"
@click="$emit('on-open', task)"></Icon>
<Icon v-else
<Icon v-else-if="task.info.status !== 4"
class="action-icon"
type="ios-play"
@click="$emit('on-resume', task)"></Icon>
<Icon type="ios-trash"
class="action-icon"
@click="$emit('on-delete', task)"></Icon>
<Icon class="action-icon"
type="ios-folder"
@click="$emit('on-open', task)"></Icon>
<Poptip placement="right-end"
:title="$t('tasks.detail')"
width="400"
Expand Down Expand Up @@ -89,7 +88,7 @@
<span>{{ calcStatus(task) }}</span>
</p>
<p>
<b>{{ $t("tasks.createTime") }}:</b>
<b>{{ $t("tasks.createTime") }}:</b>
<span>{{ new Date(task.info.startTime).format('yyyy-MM-dd hh:mm:ss') }}</span>
</p>
</div>
Expand Down Expand Up @@ -155,22 +154,17 @@ export default {
},
calcProgress(task) {
return (
this.$numeral(task.info.downSize / task.response.totalSize).format(
'0.00%'
) || '0%'
)
let progress = task.info.downSize / task.response.totalSize
return progress ? this.$numeral(task.info.downSize / task.response.totalSize).format('0.00%') : '0%'
},
calcStatus(task) {
switch (task.info.status) {
case 0:
return this.$t('tasks.wait')
case 1:
if (task.info.speed > 0) {
return this.$numeral(
(task.response.totalSize - task.info.downSize) / task.info.speed
).format('00:00:00')
if (task.info.speed > 0 && task.response.totalSize > 0) {
return this.$numeral((task.response.totalSize - task.info.downSize) / task.info.speed).format('00:00:00')
} else {
return this.$t('tasks.unknowLeft')
}
Expand All @@ -186,7 +180,7 @@ export default {
getCheckedTasks() {
return this.taskList.filter(task => {
for (let key in this.checkedMap) {
if (this.checkedMap.hasOwnProperty(key) && this.checkedMap[key] && key === task.id) {
if (this.checkedMap.hasOwnProperty(key) && this.checkedMap[key] && key === task.id) {
return true
}
}
Expand Down
1 change: 1 addition & 0 deletions front/src/views/Tasks.vue
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ export default {
const index = this.getIndexByTaskId(task.id)
if (index >= 0) {
this.taskList[index].info = task.info
this.taskList[index].response = task.response
} else {
// Load newly created tasks
this.$noSpinHttp
Expand Down

0 comments on commit 33f7e3a

Please sign in to comment.