Skip to content

A full-featured download manager.

refactor: task progress info

Dr_rOot08a419f20980
diff --git a/src/renderer/assets/icons/arrow-down.svg b/src/renderer/assets/icons/arrow-down.svg
new file mode 100644
index 00000000..96984343
--- /dev/null
+++ b/src/renderer/assets/icons/arrow-down.svg
@@ -0,0 +1,6 @@
+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24">
+ <g class="nc-icon-wrapper" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" stroke="currentColor">
+ <line data-cap="butt" data-color="color-2" fill="none" stroke-miterlimit="10" x1="12" y1="2" x2="12" y2="22"/>
+ <polyline fill="none" stroke="currentColor" stroke-miterlimit="10" points="19,15 12,22 5,15 "/>
+ </g>
+</svg>
diff --git a/src/renderer/assets/icons/arrow-up.svg b/src/renderer/assets/icons/arrow-up.svg
new file mode 100644
index 00000000..ec38630d
--- /dev/null
+++ b/src/renderer/assets/icons/arrow-up.svg
@@ -0,0 +1,6 @@
+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24">
+ <g class="nc-icon-wrapper" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" stroke="currentColor">
+ <line data-cap="butt" data-color="color-2" fill="none" stroke-miterlimit="10" x1="12" y1="22" x2="12" y2="2"/>
+ <polyline fill="none" stroke="currentColor" stroke-miterlimit="10" points="5,9 12,2 19,9 "/>
+ </g>
+</svg>
diff --git a/src/renderer/components/Icons/arrow-down.js b/src/renderer/components/Icons/arrow-down.js
new file mode 100644
index 00000000..6737219d
--- /dev/null
+++ b/src/renderer/components/Icons/arrow-down.js
@@ -0,0 +1,18 @@
+import Icon from '@/components/Icons/Icon'
+
+Icon.register({
+ 'arrow-down': {
+ 'width': 24,
+ 'height': 24,
+ 'raw': `<g class="nc-icon-wrapper" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" stroke="currentColor">
+ <line data-cap="butt" data-color="color-2" fill="none" stroke-miterlimit="10" x1="12" y1="2" x2="12" y2="22"/>
+ <polyline fill="none" stroke="currentColor" stroke-miterlimit="10" points="19,15 12,22 5,15 "/>
+ </g>`,
+ 'g': {
+ 'stroke': 'currentColor',
+ 'stroke-linecap': 'round',
+ 'stroke-linejoin': 'round',
+ 'stroke-width': '2'
+ }
+ }
+})
diff --git a/src/renderer/components/Icons/arrow-up.js b/src/renderer/components/Icons/arrow-up.js
new file mode 100644
index 00000000..17b262fa
--- /dev/null
+++ b/src/renderer/components/Icons/arrow-up.js
@@ -0,0 +1,18 @@
+import Icon from '@/components/Icons/Icon'
+
+Icon.register({
+ 'arrow-up': {
+ 'width': 24,
+ 'height': 24,
+ 'raw': `<g class="nc-icon-wrapper" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" stroke="currentColor">
+ <line data-cap="butt" data-color="color-2" fill="none" stroke-miterlimit="10" x1="12" y1="22" x2="12" y2="2"/>
+ <polyline fill="none" stroke="currentColor" stroke-miterlimit="10" points="5,9 12,2 19,9 "/>
+ </g>`,
+ 'g': {
+ 'stroke': 'currentColor',
+ 'stroke-linecap': 'round',
+ 'stroke-linejoin': 'round',
+ 'stroke-width': '2'
+ }
+ }
+})
diff --git a/src/renderer/components/Task/TaskItem.vue b/src/renderer/components/Task/TaskItem.vue
index 877a1ddc..8e8b924a 100644
--- a/src/renderer/components/Task/TaskItem.vue
+++ b/src/renderer/components/Task/TaskItem.vue
@@ -5,62 +5,33 @@
</div>
<mo-task-item-actions mode="LIST" :task="task" />
<div class="task-progress">
- <mo-task-progress :completed="Number(task.completedLength)" :total="Number(task.totalLength)" :status="task.status" />
- <el-row class="task-speed">
- <el-col :span="12" class="task-speed-left">
- <div v-if="task.totalLength > 0">
- {{ task.completedLength | bytesToSize }} / {{ task.totalLength | bytesToSize }}
- </div>
- <div v-else><!-- 等待中... --></div>
- </el-col>
- <el-col :span="12" class="task-speed-right">
- <div v-if="task.status ==='active'">
- <span>{{ task.downloadSpeed | bytesToSize }}/s</span>
- <span>
- {{
- remaining | timeFormat({
- prefix: $t('task.remaining-prefix'),
- i18n: {
- 'gt1d': $t('app.gt1d'),
- 'hour': $t('app.hour'),
- 'minute': $t('app.minute'),
- 'second': $t('app.second')
- }
- })
- }}
- </span>
- <span class="task-connections">
- <i><mo-icon name="node" width="10" height="10" /></i>
- <i>{{ task.connections }}</i>
- </span>
- </div>
- </el-col>
- </el-row>
+ <mo-task-progress
+ :completed="Number(task.completedLength)"
+ :total="Number(task.totalLength)"
+ :status="task.status"
+ />
+ <mo-task-progress-info :task="task" />
</div>
</li>
</template>
<script>
- import TaskItemActions from './TaskItemActions'
- import TaskProgress from './TaskProgress'
- import '@/components/Icons/node'
import {
- getTaskName,
getTaskFullPath,
- timeRemaining,
- bytesToSize,
- timeFormat
+ getTaskName
} from '@shared/utils'
- import {
- openItem
- } from '@/components/Native/utils'
import { TASK_STATUS } from '@shared/constants'
+ import { openItem } from '@/components/Native/utils'
+ import TaskItemActions from './TaskItemActions'
+ import TaskProgress from './TaskProgress'
+ import TaskProgressInfo from './TaskProgressInfo'
export default {
name: 'mo-task-item',
components: {
[TaskItemActions.name]: TaskItemActions,
- [TaskProgress.name]: TaskProgress
+ [TaskProgress.name]: TaskProgress,
+ [TaskProgressInfo.name]: TaskProgressInfo
},
props: {
task: {
@@ -68,26 +39,18 @@
}
},
computed: {
- taskFullName: function () {
+ taskFullName () {
return getTaskName(this.task, {
defaultName: this.$t('task.get-task-name'),
maxLen: -1
})
},
- taskName: function () {
+ taskName () {
return getTaskName(this.task, {
defaultName: this.$t('task.get-task-name')
})
- },
- remaining: function () {
- const { totalLength, completedLength, downloadSpeed } = this.task
- return timeRemaining(totalLength, completedLength, downloadSpeed)
}
},
- filters: {
- bytesToSize,
- timeFormat
- },
methods: {
onDbClick () {
const { status } = this.task
@@ -116,6 +79,7 @@
<style lang="scss">
.task-item {
position: relative;
+ min-height: 88px;
padding: 16px 12px;
background-color: $--task-item-background;
border: 1px solid $--task-item-border-color;
@@ -136,6 +100,7 @@
margin-bottom: 32px;
margin-right: 240px;
word-break: break-all;
+ min-height: 26px;
&> span {
font-size: 14px;
line-height: 26px;
@@ -146,25 +111,4 @@
-webkit-box-orient: vertical;
}
}
- .task-speed {
- font-size: 12px;
- line-height: 14px;
- min-height: 14px;
- color: #9B9B9B;
- margin-top: 8px;
- }
- .task-speed-left {
- min-height: 14px;
- text-align: left;
- }
- .task-speed-right {
- min-height: 14px;
- text-align: right;
- }
- .task-connections {
- margin-left: 8px;
- & > i {
- vertical-align: middle;
- }
- }
</style>
diff --git a/src/renderer/components/Task/TaskItemInfo.vue b/src/renderer/components/Task/TaskItemInfo.vue
index f58bd2aa..a26c2aa5 100644
--- a/src/renderer/components/Task/TaskItemInfo.vue
+++ b/src/renderer/components/Task/TaskItemInfo.vue
@@ -14,63 +14,35 @@
</div>
<mo-task-item-actions mode="ITEM" :task="task" />
<div class="task-progress">
- <mo-task-progress :completed="Number(task.completedLength)" :total="Number(task.totalLength)" :status="task.status" />
- <el-row class="task-speed">
- <el-col :span="12" class="task-speed-left">
- <div v-if="task.totalLength > 0">
- {{ task.completedLength | bytesToSize }} / {{ task.totalLength | bytesToSize }}
- </div>
- <div v-else><!-- 等待中... --></div>
- </el-col>
- <el-col :span="12" class="task-speed-right">
- <div v-if="task.status ==='active'">
- <span>{{ task.downloadSpeed | bytesToSize }}/s</span>
- <span>
- {{
- remaining | timeFormat({
- prefix: $t('task.remaining-prefix'),
- i18n: {
- 'gt1d': $t('app.gt1d'),
- 'hour': $t('app.hour'),
- 'minute': $t('app.minute'),
- 'second': $t('app.second')
- }
- })
- }}
- </span>
- <span class="task-connections">
- <i><mo-icon name="node" width="10" height="10" /></i>
- <i>{{ task.connections }}</i>
- </span>
- </div>
- </el-col>
- </el-row>
+ <mo-task-progress
+ :completed="Number(task.completedLength)"
+ :total="Number(task.totalLength)"
+ :status="task.status"
+ />
+ <mo-task-progress-info :task="task" />
</div>
</el-dialog>
</template>
<script>
import { mapActions } from 'vuex'
+ import { getTaskName } from '@shared/utils'
import TaskItemActions from './TaskItemActions'
import TaskProgress from './TaskProgress'
+ import TaskProgressInfo from './TaskProgressInfo'
import '@/components/Icons/task-start-line'
import '@/components/Icons/task-pause-line'
import '@/components/Icons/delete'
import '@/components/Icons/folder'
import '@/components/Icons/link'
import '@/components/Icons/more'
- import {
- getTaskName,
- timeRemaining,
- bytesToSize,
- timeFormat
- } from '@shared/utils'
export default {
name: 'mo-task-item-info',
components: {
[TaskItemActions.name]: TaskItemActions,
- [TaskProgress.name]: TaskProgress
+ [TaskProgress.name]: TaskProgress,
+ [TaskProgressInfo.name]: TaskProgressInfo
},
props: {
task: {
@@ -96,16 +68,8 @@
},
dialogTitle: function () {
return this.$t('task.task-info-dialog-title', { title: this.taskName })
- },
- remaining: function () {
- const { totalLength, completedLength, downloadSpeed } = this.task
- return timeRemaining(totalLength, completedLength, downloadSpeed)
}
},
- filters: {
- bytesToSize,
- timeFormat
- },
methods: {
handleClose (done) {
this.$store.dispatch('task/hideTaskItemInfoDialog')
@@ -147,25 +111,43 @@
top: 30px;
right: 20px;
}
- .task-speed {
+ .task-name {
+ color: #505753;
+ margin-bottom: 32px;
+ margin-right: 240px;
+ word-break: break-all;
+ min-height: 26px;
+ &> span {
+ font-size: 14px;
+ line-height: 26px;
+ overflow : hidden;
+ text-overflow: ellipsis;
+ display: -webkit-box;
+ -webkit-line-clamp: 2;
+ -webkit-box-orient: vertical;
+ }
+ }
+ .task-progress-info {
font-size: 12px;
line-height: 14px;
min-height: 14px;
color: #9B9B9B;
margin-top: 8px;
}
- .task-speed-left {
+ .task-progress-info-left {
min-height: 14px;
text-align: left;
}
- .task-speed-right {
+ .task-progress-info-right {
min-height: 14px;
text-align: right;
}
- .task-connections {
- margin-left: 8px;
- & > i {
- vertical-align: middle;
+ .task-speed-info {
+ & > .task-speed-text {
+ margin-left: 8px;
+ & > i {
+ vertical-align: middle;
+ }
}
}
</style>