diff --git a/templates/auto_pt/downloading.html b/templates/auto_pt/downloading.html
index f96fe98..a94b8f8 100644
--- a/templates/auto_pt/downloading.html
+++ b/templates/auto_pt/downloading.html
@@ -6,10 +6,21 @@
任务管理
{% include 'admin/includes/css-part.html' %}
+
-
复制HASH
- 暂停刷新
+ 暂停刷新
+ {# 开始刷新#}
+
+ 开始刷新
+
+ 5S
+ 15S
+ 30S
+ 60S
+
+
-
-
@@ -77,36 +97,67 @@
+ width="75"
+ label="上传">
-
+
+
+
+
+
+
+
+
+
{# #}
{# #}
{# #}
{# #}
@@ -120,7 +171,7 @@
-
+
@@ -190,6 +241,8 @@
torrents: [],
dialogFormVisible: false,
timer: {},
+ interval: 5000,
+ refresh: false,
downloader_id: 0,
torrent: {
name: '',
@@ -206,17 +259,31 @@
last_activity: '',
added_on: '',
tracker: '',
- }
+ },
+ customColors: [
+ {color: '#f56c6c', percentage: 20},
+ {color: '#e6a23c', percentage: 40},
+ {color: '#5cb87a', percentage: 60},
+ {color: '#1989fa', percentage: 80},
+ {color: '#6f7ad3', percentage: 100}
+ ]
},
beforeMount() {
- this.get_downloader()
-
},
mounted() {
+
+ this.get_downloader()
console.log("下载器:", this.downloaders)
- this.timer = setInterval(() => {
- this.get_downloading(this.downloader_id)
- }, 5000)
+
+ },
+ // 清除定时器,不然页面会卡死
+ beforeDestroy() {
+ this.$once('hook:beforeDestroy',
+ () => {
+ clearInterval(this.timer)
+ this.timer = null
+ }
+ )
},
watch: {},
methods: {
@@ -248,13 +315,20 @@
})
},
handleTabClick(tab, event) {
- console.log(tab)
+ const loading = this.$loading({
+ lock: true,//lock的修改符--默认是false
+ text: 'Loading',//显示在加载图标下方的加载文案
+ spinner: 'el-icon-loading',//自定义加载图标类名
+ background: 'rgba(0, 0, 0, 0.7)',//遮罩层颜色
+ target: document.querySelector('#table')//loadin覆盖的dom元素节点
+ });
+ {#console.log(tab)#}
console.log(tab.$attrs.id)
this.loading = true
{#this.torrents = []#}
this.downloader_id = tab.$attrs.id
this.get_downloading(this.downloader_id)
- this.loading = false
+ loading.close()
},
get_downloading(downloader_id) {
axios.get(
@@ -265,15 +339,19 @@
}
}
).then(res => {
+
if (res.data.code === 0) {
console.log(res.data.data)
this.torrents = res.data.data
}
})
},
+ // 执行格式化文件大小
handleSize(row, column, cellValue, index) {
return this.renderSize(cellValue)
- },
+ }
+ ,
+ // 格式化文件大小
renderSize(value) {
if (null == value || value == '') {
return "0";
@@ -285,13 +363,19 @@
var size = srcsize / Math.pow(1024, index);
size = size.toFixed(2);//保留的小数位数
return size + unitArr[index];
- },
+ }
+ ,
+ // 格式化进度
handlePercent(row, column, cellValue, index) {
return (cellValue * 100).toFixed(2) + '%'
- },
+ }
+ ,
+ // 格式化分享率
handleRatio(row, column, cellValue, index) {
return cellValue.toFixed(4)
- },
+ }
+ ,
+ // 双击任务事件
handleRow(row, column, event) {
console.log(row)
this.torrent = row
@@ -300,12 +384,38 @@
console.log(row.name)
console.log(column)
console.log(event)
- },
+ }
+ ,
// 阻止默认右键菜单弹出
rtClick(row, column, event) {
// 阻止默认右键菜单弹出
event.preventDefault()
}
+ ,
+ handleRefresh(command) {
+ console.log(this.refresh)
+ this.refresh = true
+ this.interval = command * 1000
+ this.$message({
+ type: 'success',
+ message: '下载任务将每' + command + '秒刷新一次,如需暂停,请点击按钮!'
+ });
+ this.timer = setInterval(() => {
+ this.get_downloading(this.downloader_id)
+ }, this.interval)
+
+ }
+ ,
+ clearTimer() {
+ this.refresh = false
+ console.log(this.refresh)
+ this.$message({
+ type: 'warning',
+ message: '任务刷新已暂停!'
+ });
+ window.clearInterval(this.timer)
+ this.timer = null
+ }
}
});