From d9b33ef28cb66645fb9f063e979d3f909a20591f Mon Sep 17 00:00:00 2001 From: jmal Date: Mon, 28 Aug 2023 18:29:56 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E9=9D=9E=E5=88=86=E4=BA=AB=E7=95=8C?= =?UTF-8?q?=E9=9D=A2=E6=B7=BB=E5=8A=A0=E5=A4=8D=E5=88=B6=E4=B8=8B=E8=BD=BD?= =?UTF-8?q?=E9=93=BE=E6=8E=A5=E7=9A=84=E9=80=89=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/ShowFile/ShowFile.vue | 37 +++++++++++++++++++++++++--- src/views/public/share/shareList.vue | 6 ++--- 2 files changed, 37 insertions(+), 6 deletions(-) diff --git a/src/components/ShowFile/ShowFile.vue b/src/components/ShowFile/ShowFile.vue index 2a164ae..c88f20c 100644 --- a/src/components/ShowFile/ShowFile.vue +++ b/src/components/ShowFile/ShowFile.vue @@ -258,6 +258,7 @@ v-if=" item.operation === 'unFavorite' || item.operation === 'favorite' " + class="menu-option" @click="menusOperations(item.operation)" @mouseover.prevent.stop=" menuFavoriteOver(index, rowContextData.isFavorite) @@ -870,6 +871,7 @@ import EditElement from "@/views/markdown/EditElement"; import OfficePreview from "@/components/preview/OfficePreview"; import ShareDialog from "@/components/ShareDialog/index.vue"; import {getUsername} from "@/api/user"; +import Clipboard from "clipboard"; export default { name: "ShowFile", @@ -2690,7 +2692,8 @@ export default { id: row.id, currentDirectory: encodeURI(this.$route.query.path), pageIndex: this.pagination.pageIndex, - pageSize: this.pagination.pageSize + pageSize: this.pagination.pageSize, + folder: this.$route.query.folder }) .then(res => { this.loadData(res, onLoad); @@ -2709,7 +2712,8 @@ export default { id: row.mountFileId || row.id, currentDirectory: encodeURI(this.$route.query.path), pageIndex: this.pagination.pageIndex, - pageSize: this.pagination.pageSize + pageSize: this.pagination.pageSize, + folder: this.$route.query.folder }) .then(res => { this.loadData(res, onLoad); @@ -3191,13 +3195,17 @@ export default { if (!row.isFolder) { this.menus.splice(-2, 0, { iconClass: "duplicate", label: "创建副本", operation: "duplicate" }) } - if (row.isShare && !row.shareBase) { + if ((row.isShare && !row.shareBase) || row.ossFolder) { // 删除分享选项 let index = this.menus.findIndex(item => item.operation === "share") if (index > -1) { this.menus.splice(index, 1) } } + if (row.isShare && !row.isPrivacy) { + // 添加复制下载链接选项 + this.menus.splice(-2, 0, { iconClass: "menu-fuzhi", label: "复制下载链接", operation: "copyDownloadLink" }) + } } this.preliminaryRowData(row); }, @@ -3449,6 +3457,10 @@ export default { // 下载 this.downloadFile(); break; + case "copyDownloadLink": + // 复制下载链接 + this.copyDownloadLink(this.rowContextData) + break; case "remove": // 删除 this.deleteFile(); @@ -3771,6 +3783,25 @@ export default { }); } }, + // 复制下载链接 + copyDownloadLink(row) { + let url = window.location.origin + fileConfig.previewUrl(this.$store.getters.name, row, undefined, undefined) + let clipboard = new Clipboard('.newFileMenu', { + text: function () { + return url + } + }) + clipboard.on('success', e => { + this.$message({message: '复制成功', type: 'success', duration: 1000}); + // 释放内存 + clipboard.destroy() + }) + clipboard.on('error', e => { + // 不支持复制 + this.$message({message: '该浏览器不支持自动复制', type: 'warning', duration: 1000}); + clipboard.destroy() + }) + }, // 收藏/取消收藏 favoriteOperating(isFavorite) { const fileIds = this.getSelectIdList(); diff --git a/src/views/public/share/shareList.vue b/src/views/public/share/shareList.vue index 231be5b..03045b0 100644 --- a/src/views/public/share/shareList.vue +++ b/src/views/public/share/shareList.vue @@ -356,12 +356,12 @@ export default { singleMenus: [ {iconClass: 'menu-open', label: '打开', operation: 'open'}, {iconClass: 'menu-download', label: '下载', operation: 'download'}, - {iconClass: 'menu-fuzhi', label: '复制下载连接', operation: 'copyDownloadUrl'}, + {iconClass: 'menu-fuzhi', label: '复制下载链接', operation: 'copyDownloadUrl'}, ], singleMenusEdit: [ {iconClass: 'menu-open', label: '打开', operation: 'open'}, {iconClass: 'menu-download', label: '下载', operation: 'download'}, - {iconClass: 'menu-fuzhi', label: '复制下载连接', operation: 'copyDownloadUrl'}, + {iconClass: 'menu-fuzhi', label: '复制下载链接', operation: 'copyDownloadUrl'}, ], multipleMenus: [ {iconClass: 'menu-download', label: '下载', operation: 'download'}, @@ -1042,7 +1042,7 @@ export default { }); } }, - // 复制下载连接 + // 复制下载链接 copyDownloadLink(url) { let clipboard = new Clipboard('.menu-option', { text: function () {