Skip to content

A full-featured download manager.

feat: task detail files show completed percent

Dr_rOot3ffce0566b6a
diff --git a/src/renderer/components/TaskDetail/TaskFiles.vue b/src/renderer/components/TaskDetail/TaskFiles.vue
index b175de42..4c76a6ca 100644
--- a/src/renderer/components/TaskDetail/TaskFiles.vue
+++ b/src/renderer/components/TaskDetail/TaskFiles.vue
@@ -26,18 +26,25 @@
<template slot-scope="scope">{{ scope.row.extension | removeExtensionDot }}</template>
</el-table-column>
<el-table-column
- :label="$t('task.file-size')"
+ v-if="mode === 'DETAIL'"
+ :label="`%`"
align="right"
- width="85">
- <template slot-scope="scope">{{ scope.row.length | bytesToSize }}</template>
+ width="50">
+ <template slot-scope="scope">{{ calcProgress(scope.row.length, scope.row.completedLength, 1) }}</template>
</el-table-column>
<el-table-column
v-if="mode === 'DETAIL'"
- :label="$t('task.file-completed-size')"
+ :label="`✓`"
align="right"
- width="95">
+ width="85">
<template slot-scope="scope">{{ scope.row.completedLength | bytesToSize }}</template>
</el-table-column>
+ <el-table-column
+ :label="$t('task.file-size')"
+ align="right"
+ width="85">
+ <template slot-scope="scope">{{ scope.row.length | bytesToSize }}</template>
+ </el-table-column>
</el-table>
</div>
<el-row class="file-filters" :gutter="12">
@@ -84,6 +91,7 @@
} from '@shared/constants'
import {
bytesToSize,
+ calcProgress,
filterVideoFiles,
filterAudioFiles,
filterImageFiles,
@@ -149,6 +157,7 @@
}
},
methods: {
+ calcProgress,
toggleAllSelection () {
if (!this.$refs.torrentTable) {
return
diff --git a/src/shared/utils/index.js b/src/shared/utils/index.js
index ffec06b2..f4b8a75d 100644
--- a/src/shared/utils/index.js
+++ b/src/shared/utils/index.js
@@ -101,14 +101,14 @@ export function peerIdParser (str) {
return result
}
-export function calcProgress (totalLength, completedLength) {
+export function calcProgress (totalLength, completedLength, decimal = 2) {
const total = parseInt(totalLength, 10)
const completed = parseInt(completedLength, 10)
if (total === 0 || completed === 0) {
return 0
}
const percentage = completed / total * 100
- const result = parseFloat(percentage.toFixed(2))
+ const result = parseFloat(percentage.toFixed(decimal))
return result
}