From e3ca303c9e750779de3809aa96866afa630d8f81 Mon Sep 17 00:00:00 2001 From: jmal Date: Mon, 1 May 2023 17:00:31 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E9=A2=84=E8=A7=88=E5=88=86=E4=BA=AB?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E9=93=BE=E6=8E=A5=E5=8A=A0=E4=B8=8A=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/office/OnlyOfficeEditor.vue | 2 +- src/components/preview/AudioPreview.vue | 2 +- src/components/preview/ImageViewer.vue | 2 +- src/components/preview/OfficePreview.vue | 2 +- src/utils/file-config.js | 10 +++++----- src/views/public/share/shareList.vue | 2 +- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/components/office/OnlyOfficeEditor.vue b/src/components/office/OnlyOfficeEditor.vue index 69b3634..f26db6e 100644 --- a/src/components/office/OnlyOfficeEditor.vue +++ b/src/components/office/OnlyOfficeEditor.vue @@ -123,7 +123,7 @@ export default { } this.fileUrl = window.location.origin + fileConfig.previewUrl(this.$store.state.user.name, this.file, this.$store.getters.token) if(this.readOnly && window.shareId){ - this.fileUrl = window.location.origin + fileConfig.publicPreviewUrl(this.file.id, window.shareId, this.$store.getters.shareToken) + this.fileUrl = window.location.origin + fileConfig.publicPreviewUrl(this.file, window.shareId, this.$store.getters.shareToken) } let fileKey = `${new Date(this.file.updateDate).getTime()}-${SparkMD5.hash(this.file.id)}` diff --git a/src/components/preview/AudioPreview.vue b/src/components/preview/AudioPreview.vue index ae4074f..c4a07e3 100644 --- a/src/components/preview/AudioPreview.vue +++ b/src/components/preview/AudioPreview.vue @@ -60,7 +60,7 @@ export default { console.log('this.$refs', this.$refs) let url = fileConfig.previewUrl(this.$store.state.user.name, newFile, this.$store.getters.token) if (this.$store.getters.token === undefined) { - url = fileConfig.publicPreviewUrl(newFile.id, window.shareId, this.$store.getters.shareToken); + url = fileConfig.publicPreviewUrl(newFile, window.shareId, this.$store.getters.shareToken); } let music = newFile.music let fileName = newFile.name.substring(0, newFile.name.length - newFile.suffix.length - 1) diff --git a/src/components/preview/ImageViewer.vue b/src/components/preview/ImageViewer.vue index cb30f85..d785106 100644 --- a/src/components/preview/ImageViewer.vue +++ b/src/components/preview/ImageViewer.vue @@ -117,7 +117,7 @@ export default { getImageUrl(element) { let url = fileConfig.previewUrl(this.$store.state.user.name, element, this.$store.getters.token) if (this.shareId) { - url = fileConfig.publicPreviewUrl(element.id, window.shareId, this.$store.getters.shareToken); + url = fileConfig.publicPreviewUrl(element, window.shareId, this.$store.getters.shareToken); } return url }, diff --git a/src/components/preview/OfficePreview.vue b/src/components/preview/OfficePreview.vue index eee4e6d..c0b98e4 100644 --- a/src/components/preview/OfficePreview.vue +++ b/src/components/preview/OfficePreview.vue @@ -225,7 +225,7 @@ export default { } this.fileUrl = window.location.origin + fileConfig.previewUrl(this.$store.state.user.name, this.file, this.$store.getters.token) if(this.readOnly && window.shareId){ - this.fileUrl = window.location.origin + fileConfig.publicPreviewUrl(this.file.id, window.shareId, this.$store.getters.shareToken) + this.fileUrl = window.location.origin + fileConfig.publicPreviewUrl(this.file, window.shareId, this.$store.getters.shareToken) } }, } diff --git a/src/utils/file-config.js b/src/utils/file-config.js index cb3d893..4265197 100644 --- a/src/utils/file-config.js +++ b/src/utils/file-config.js @@ -56,16 +56,16 @@ export default { window.open(this.publicDownloadUrl(shareId, file, shareToken), '_self') }, // 共享文件预览 - publicPreview: function(fileId, shareId, shareToken) { - const url = this.publicPreviewUrl(fileId, shareId, shareToken) + publicPreview: function(file, shareId, shareToken) { + const url = this.publicPreviewUrl(file, shareId, shareToken) window.open(url, '_blank') }, // 共享文件预览Url - publicPreviewUrl: function(fileId, shareId, shareToken) { + publicPreviewUrl: function(file, shareId, shareToken) { if (!shareToken) { shareToken = "none" } - return `${this.baseUrl}/public/s/preview?fileId=${fileId}&shareId=${shareId}&shareToken=${shareToken}` + return `${this.baseUrl}/public/s/preview/${file.name}?fileId=${file.id}&shareId=${shareId}&shareToken=${shareToken}` }, // 共享文件打包下载 publicPackageDownload: function(shareId, fileIds, shareToken) { @@ -76,7 +76,7 @@ export default { if (!shareToken) { shareToken = "none" } - return window.location.origin + `${this.baseUrl}/public/s/download?fileId=${file.id}&shareId=${shareId}&shareToken=${shareToken}` + return window.location.origin + `${this.baseUrl}/public/s/download/${file.name}?fileId=${file.id}&shareId=${shareId}&shareToken=${shareToken}` }, // 共享文件打包下载Url publicPackageDownloadUrl: function(shareId, fileIds, shareToken) { diff --git a/src/views/public/share/shareList.vue b/src/views/public/share/shareList.vue index cc66455..db47e02 100644 --- a/src/views/public/share/shareList.vue +++ b/src/views/public/share/shareList.vue @@ -1032,7 +1032,7 @@ export default { return } // 打开文件 - fileConfig.publicPreview(row.id, this.shareId, this.$store.getters.shareToken) + fileConfig.publicPreview(row, this.shareId, this.$store.getters.shareToken) } }, /**