From 397facf4c5eaa1702ca157111e4eee2002c23eb0 Mon Sep 17 00:00:00 2001 From: MarSeventh <1193267292@qq.com> Date: Sat, 14 Dec 2024 17:59:02 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AE=A1=E7=90=86=E7=AB=AF=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E6=89=B9=E9=87=8F=E9=BB=91=E5=90=8D=E5=8D=95=E3=80=81=E7=99=BD?= =?UTF-8?q?=E5=90=8D=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/AdminDashBoard.vue | 98 ++++++++++++++++++++++++++++-------- 1 file changed, 78 insertions(+), 20 deletions(-) diff --git a/src/views/AdminDashBoard.vue b/src/views/AdminDashBoard.vue index f00decc..686c470 100644 --- a/src/views/AdminDashBoard.vue +++ b/src/views/AdminDashBoard.vue @@ -46,6 +46,14 @@ 批量下载 + + + 批量黑名单 + + + + 批量白名单 + @@ -415,18 +423,18 @@ methods: { }).then(() => { this.fetchWithAuth(`/api/manage/delete/${key}`, { method: 'GET' }) .then(response => { - if (response.ok) { - const fileIndex = this.tableData.findIndex(file => file.name === key); - if (fileIndex !== -1) { - this.tableData.splice(fileIndex, 1); + if (response.ok) { + const fileIndex = this.tableData.findIndex(file => file.name === key); + if (fileIndex !== -1) { + this.tableData.splice(fileIndex, 1); + } + } else { + return Promise.reject('请求失败'); } - } else { - return Promise.reject('请求失败'); - } }) .then(() => { - this.updateStats(); - this.$message.success('删除成功!'); + this.updateStats(); + this.$message.success('删除成功!'); }) .catch(() => this.$message.error('删除失败,请检查网络连接')); }).catch(() => this.$message.info('已取消删除')); @@ -441,17 +449,17 @@ methods: { Promise.all(promises) .then(results => { - results.forEach((response, index) => { - if (response.ok) { - const fileIndex = this.tableData.findIndex(file => file.name === this.selectedFiles[index].name); - if (fileIndex !== -1) { - this.tableData.splice(fileIndex, 1); - } - } - }); - this.selectedFiles = []; - this.updateStats(); - this.$message.success('批量删除成功!'); + results.forEach((response, index) => { + if (response.ok) { + const fileIndex = this.tableData.findIndex(file => file.name === this.selectedFiles[index].name); + if (fileIndex !== -1) { + this.tableData.splice(fileIndex, 1); + } + } + }); + this.selectedFiles = []; + this.updateStats(); + this.$message.success('批量删除成功!'); }) .catch(() => this.$message.error('批量删除失败,请检查网络连接')); }).catch(() => this.$message.info('已取消批量删除')); @@ -548,8 +556,58 @@ methods: { this.handleBatchDelete(); } else if (command === 'download') { this.handleBatchDownload(); + } else if (command === 'ban') { + this.handleBatchBlock(); + } else if (command === 'white') { + this.handleBatchWhite(); } }, + handleBatchBlock(){ + this.$confirm('此操作将把选中的文件加入黑名单, 是否继续?', '提示', { + confirmButtonText: '确定', + cancelButtonText: '取消', + type: 'warning' + }).then(() => { + const promises = this.selectedFiles.map(file => this.fetchWithAuth(`/api/manage/block/${file.name}`, { method: 'GET' })); + + Promise.all(promises) + .then(results => { + results.forEach((response, index) => { + if (response.ok) { + const fileIndex = this.tableData.findIndex(file => file.name === this.selectedFiles[index].name); + if (fileIndex !== -1) { + this.tableData[fileIndex].metadata.ListType = 'Block'; + } + } + }); + this.$message.success('批量加入黑名单成功!'); + }) + .catch(() => this.$message.error('批量加入黑名单失败,请检查网络连接')); + }).catch(() => this.$message.info('已取消批量加入黑名单')); + }, + handleBatchWhite(){ + this.$confirm('此操作将把选中的文件加入白名单, 是否继续?', '提示', { + confirmButtonText: '确定', + cancelButtonText: '取消', + type: 'warning' + }).then(() => { + const promises = this.selectedFiles.map(file => this.fetchWithAuth(`/api/manage/white/${file.name}`, { method: 'GET' })); + + Promise.all(promises) + .then(results => { + results.forEach((response, index) => { + if (response.ok) { + const fileIndex = this.tableData.findIndex(file => file.name === this.selectedFiles[index].name); + if (fileIndex !== -1) { + this.tableData[fileIndex].metadata.ListType = 'White'; + } + } + }); + this.$message.success('批量加入白名单成功!'); + }) + .catch(() => this.$message.error('批量加入白名单失败,请检查网络连接')); + }).catch(() => this.$message.info('已取消批量加入白名单')); + }, handleBatchDownload() { // 将选中文件打包成 zip 文件下载 const zip = new JSZip();