diff --git a/auto_pt/views.py b/auto_pt/views.py index 74a1203..080666f 100644 --- a/auto_pt/views.py +++ b/auto_pt/views.py @@ -175,6 +175,9 @@ def get_downloading(request): def control_torrent(request): ids = request.POST.get('ids') command = request.POST.get('command') + delete_files = request.POST.get('delete_files') + category = request.POST.get('category') + enable = request.POST.get('enable') downloader_id = request.POST.get('downloader_id') print(request.POST) # print(command, type(ids), downloader_id) @@ -192,7 +195,11 @@ def control_torrent(request): # 根据指令字符串定位函数 command_exec = getattr(qb_client.torrents, command) print(command_exec) - command_exec(torrent_hashes=ids.split(','), enable=True) + command_exec( + torrent_hashes=ids.split(','), + category=category, + delete_files=delete_files, + enable=enable, ) # 延缓2秒等待操作生效 time.sleep(2) except Exception as e: diff --git a/templates/auto_pt/downloading.html b/templates/auto_pt/downloading.html index be4f051..0dc528c 100644 --- a/templates/auto_pt/downloading.html +++ b/templates/auto_pt/downloading.html @@ -44,183 +44,220 @@ 操作 - 删除 - 分类 - 限速 + + 删除任务 + + + 修改分类 + + {# 限速#} {# 更改路径#} - {# 复制链接#} - {# 复制HASH#} - 暂停刷新 - {# 开始刷新#} - - 开始刷新 - - 3S - 5S - 10S - 15S - - -
- 总分享率: - + +
+ + +
+ + + 取 消 + 确 定 - 剩余空间: - +
+ +
+ + + + +
+ + + 取 消 + 确 定 - 历史下载: - +
+
+ + - 历史上传: - + + - 本次下载: + + + + + + + + v-text="'本次下载:' + renderSize(server_state.dl_info_data)"> - 下载速度: + + v-text="'下载速度:' + renderSize(server_state.dl_info_speed)"> - 本次上传: + + v-text="'本次上传:' + renderSize(server_state.up_info_data)"> - 上传速度: + + v-text="'上传速度:' + renderSize(server_state.up_info_speed) + '/S'">
-
- +
+ + - - - - - - - - {# #} - - - - - - - {# #} - - {# #} - - - {# #} - - {# #} - {# #} - {# #} - {# #} - + type="selection"> + + + + + + + {# #} + + + + + + + + + {# #} + + + {# #} + + {# #} + {# #} + {# #} + {# #} +
@@ -316,7 +353,8 @@ torrents: [], dialogFormVisible: false, timer: {}, - interval: 5000, + deleteForm: false, + categoryForm: false, refresh: false, downloader_id: 0, torrent: { @@ -349,7 +387,10 @@ value: '' } ], - server_state: {} + categories: [], + category: '', + server_state: {}, + delete_files: false, }, beforeMount() { }, @@ -367,6 +408,9 @@ {#console.log(this.stateFilters)#} this.get_downloader() console.log("下载器:", this.downloaders.length) + this.timer = setInterval(() => { + this.get_downloading(this.downloaders[0].id) + }, 1500) }, // 清除定时器,不然页面会卡死 beforeDestroy() { @@ -383,14 +427,26 @@ this.selected_rows = rows console.log(this.selected_rows) }, + rowKey(row) { + console.log(row.hash) + return row.hash + }, handleDelete() { + console.log(this.delete_files) + {#this.deleteForm = true#} + this.handleSelected('delete', '', this.delete_files) + this.deleteForm = false + this.delete_files = false }, setCategory() { + this.handleSelected('set_category', this.category) + this.categoryForm = false + this.category = '' }, limitSpeed() { }, {#setLocation(){},#} - handleSelected(command) { + handleSelected(command, category = '', delete_files = false, enable = true) { let ids = [] if (this.selected_rows.length <= 0) { this.$message({ @@ -406,6 +462,8 @@ let data = new FormData() data.append('ids', ids) data.append('command', command) + data.append('enable', enable) + data.append('category', category) data.append('downloader_id', this.downloader_id) axios.post( "{% url "control_torrent" %}", @@ -413,12 +471,11 @@ ).then(res => { console.log(res.data) this.get_downloading(this.downloader_id) - clearInterval(this.timer) - this.timer = null this.$message({ type: 'success', message: '指令发送成功!!' }) + this.$refs.plxTable.clearSelection(); }).catch(res => { this.$message({ type: 'warning', @@ -471,6 +528,8 @@ loading.close() }, get_downloading(downloader_id) { + clearInterval(this.timer) + this.timer = null axios.get( "{% url "downloading" %}", { @@ -486,12 +545,18 @@ // 获取分类列表 let categories = res.data.data.categories // 任务状态过滤器数据 + this.categoryFilters = [] + this.categories = [] for (let x in res.data.data.categories) { {#console.log(download_state[x])#} this.categoryFilters.push({ 'text': x, 'value': x }) + this.categories.push({ + 'label': x, + 'value': x + }) } this.server_state = res.data.data.server_state //this.$message({ @@ -506,11 +571,18 @@ }) } }) + this.timer = setInterval(() => { + this.get_downloading(downloader_id) + }, 1500) }, // 执行格式化文件大小 handleSize(row, column, cellValue, index) { return this.renderSize(cellValue) }, + handleSpeed(row, column, cellValue, index) { + return this.renderSize(cellValue) != 0 ? this.renderSize(cellValue) + '/S' : '' + }, + // 执行格式化文件大小 handleState(row, column, cellValue, index) { {#('state'))#} @@ -553,19 +625,19 @@ // 阻止默认右键菜单弹出 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) - - }, + {#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)