From 7f462e48dddb6c4d1d931dccb6fd44b64bfbbf0c Mon Sep 17 00:00:00 2001 From: MarSeventh <1193267292@qq.com> Date: Sun, 29 Sep 2024 17:04:38 +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=9F=A5=E7=9C=8B=E6=96=87=E4=BB=B6=E8=AF=A6=E6=83=85=EF=BC=9B?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E4=B8=8A=E4=BC=A0IP=E7=BB=9F=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/UploadForm.vue | 7 +- src/router/index.js | 31 +++++ src/views/AdminDashBoard.vue | 235 +++++++++++++++++++++++++++++++--- src/views/UserConfig.vue | 101 +++++++++++++++ 4 files changed, 352 insertions(+), 22 deletions(-) create mode 100644 src/views/UserConfig.vue diff --git a/src/components/UploadForm.vue b/src/components/UploadForm.vue index f663765..bdc64cb 100644 --- a/src/components/UploadForm.vue +++ b/src/components/UploadForm.vue @@ -43,9 +43,9 @@ - - - + + + @@ -73,16 +145,19 @@ import { mapGetters } from 'vuex'; export default { data() { return { - Number: 0, - showLogoutButton: false, - tableData: [], - search: '', - currentPage: 1, - pageSize: 15, - selectedFiles: [], - sortOption: 'dateDesc', - isUploading: false - }; + Number: 0, + showLogoutButton: false, + tableData: [], + search: '', + currentPage: 1, + pageSize: 15, + selectedFiles: [], + sortOption: 'dateDesc', + isUploading: false, + showdetailDialog: false, + detailFile: null, + activeUrlTab: 'originUrl', + } }, computed: { ...mapGetters(['credentials']), @@ -106,6 +181,27 @@ computed: { }, sortIcon() { return this.sortOption === 'dateDesc' ? 'sort-amount-down' : 'sort-alpha-up'; + }, + dialogWidth() { + return window.innerWidth > 768 ? '60%' : '90%'; + }, + accessType() { + if (this.detailFile?.metadata?.ListType === 'White') { + return '正常'; + } else if (this.detailFile?.metadata?.ListType === 'Block' || this.detailFile?.metadata?.Label === 'adult') { + return '受限'; + } else { + return '正常'; + } + }, + allUrl() { + return { + 'originUrl': `${document.location.origin}/file/${this.detailFile?.name}`, + 'mdUrl': `![${this.detailFile?.metadata?.FileName || this.detailFile?.name}](${document.location.origin}/file/${this.detailFile?.name})`, + 'htmlUrl': `${this.detailFile?.metadata?.FileName || this.detailFile?.name}`, + 'bbUrl': `[img]${document.location.origin}/file/${this.detailFile?.name}[/img]`, + 'tgId': this.detailFile?.metadata?.TgFileId || '未知' + } } }, watch: { @@ -123,6 +219,110 @@ methods: { refreshDashboard() { location.reload(); }, + handleDownload(key) { + const link = document.createElement('a'); + link.href = `/file/${key}`; + link.download = key; + link.click(); + }, + openDetailDialog(index, key) { + this.detailFile = this.paginatedTableData[index]; + this.showdetailDialog = true; + }, + handleTabClick(tab) { + this.activeUrlTab = tab.props.name; + }, + handleUrlClick(event) { + // 复制到剪贴板 + navigator.clipboard.writeText(event.target.value) + .then(() => { + this.$message({ + type: 'success', + message: '复制成功' + }); + }) + .catch(() => { + this.$message({ + type: 'error', + message: '复制失败' + }); + }); + }, + handleDetailDelete(key) { + this.$confirm('此操作将永久删除该文件, 是否继续?', '提示', { + confirmButtonText: '确定', + cancelButtonText: '取消', + type: 'warning' + }).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); + } + } else { + return Promise.reject('请求失败'); + } + }) + .then(() => { + this.updateStats(); + this.$message.success('删除成功!'); + this.showdetailDialog = false; + }) + .catch(() => this.$message.error('删除失败,请检查网络连接')); + }).catch(() => this.$message.info('已取消删除')); + }, + handleBlock(key) { + this.$confirm('此操作将把该文件加入黑名单, 是否继续?', '提示', { + confirmButtonText: '确定', + cancelButtonText: '取消', + type: 'warning' + }).then(() => { + this.fetchWithAuth(`/api/manage/block/${key}`, { method: 'GET' }) + .then(response => { + if (response.ok) { + const fileIndex = this.tableData.findIndex(file => file.name === key); + if (fileIndex !== -1) { + this.tableData[fileIndex].metadata.ListType = 'Block'; + } + } else { + return Promise.reject('请求失败'); + } + }) + .then(() => { + this.$message.success('加入黑名单成功!'); + }) + .catch(() => this.$message.error('加入黑名单失败,请检查网络连接')); + }).catch( + () => console.log('已取消加入黑名单') + ); + }, + handleWhite(key) { + this.$confirm('此操作将把该文件加入白名单, 是否继续?', '提示', { + confirmButtonText: '确定', + cancelButtonText: '取消', + type: 'warning' + }).then(() => { + this.fetchWithAuth(`/api/manage/white/${key}`, { method: 'GET' }) + .then(response => { + if (response.ok) { + const fileIndex = this.tableData.findIndex(file => file.name === key); + if (fileIndex !== -1) { + this.tableData[fileIndex].metadata.ListType = 'White'; + } + } else { + return Promise.reject('请求失败'); + } + }) + .then(() => { + this.$message.success('加入白名单成功!'); + }) + .catch(() => this.$message.error('加入白名单失败,请检查网络连接')); + }).catch( + () => console.log('已取消加入白名单') + ); + }, async fetchWithAuth(url, options = {}) { // 开发环境, url 前面加上 /api // url = `/api${url}`; @@ -217,7 +417,7 @@ methods: { this.$router.push('/'); }, handleGoToAdmin() { - window.location.href = '/admin-detail'; + this.$router.push('/userConfig'); }, handleCopy(index, key) { const text = `${document.location.origin}/file/${key}`; @@ -565,7 +765,6 @@ mounted() { .overlay-buttons { display: flex; - gap: 10px; pointer-events: auto; } diff --git a/src/views/UserConfig.vue b/src/views/UserConfig.vue new file mode 100644 index 0000000..e6c0755 --- /dev/null +++ b/src/views/UserConfig.vue @@ -0,0 +1,101 @@ + + + + + \ No newline at end of file