perf: 预览分享文件链接加上文件名

This commit is contained in:
jmal 2023-05-01 17:00:31 +08:00
parent 19e2fdbbb2
commit e3ca303c9e
6 changed files with 10 additions and 10 deletions

View File

@ -123,7 +123,7 @@ export default {
} }
this.fileUrl = window.location.origin + fileConfig.previewUrl(this.$store.state.user.name, this.file, this.$store.getters.token) this.fileUrl = window.location.origin + fileConfig.previewUrl(this.$store.state.user.name, this.file, this.$store.getters.token)
if(this.readOnly && window.shareId){ 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)}` let fileKey = `${new Date(this.file.updateDate).getTime()}-${SparkMD5.hash(this.file.id)}`

View File

@ -60,7 +60,7 @@ export default {
console.log('this.$refs', this.$refs) console.log('this.$refs', this.$refs)
let url = fileConfig.previewUrl(this.$store.state.user.name, newFile, this.$store.getters.token) let url = fileConfig.previewUrl(this.$store.state.user.name, newFile, this.$store.getters.token)
if (this.$store.getters.token === undefined) { 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 music = newFile.music
let fileName = newFile.name.substring(0, newFile.name.length - newFile.suffix.length - 1) let fileName = newFile.name.substring(0, newFile.name.length - newFile.suffix.length - 1)

View File

@ -117,7 +117,7 @@ export default {
getImageUrl(element) { getImageUrl(element) {
let url = fileConfig.previewUrl(this.$store.state.user.name, element, this.$store.getters.token) let url = fileConfig.previewUrl(this.$store.state.user.name, element, this.$store.getters.token)
if (this.shareId) { 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 return url
}, },

View File

@ -225,7 +225,7 @@ export default {
} }
this.fileUrl = window.location.origin + fileConfig.previewUrl(this.$store.state.user.name, this.file, this.$store.getters.token) this.fileUrl = window.location.origin + fileConfig.previewUrl(this.$store.state.user.name, this.file, this.$store.getters.token)
if(this.readOnly && window.shareId){ 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)
} }
}, },
} }

View File

@ -56,16 +56,16 @@ export default {
window.open(this.publicDownloadUrl(shareId, file, shareToken), '_self') window.open(this.publicDownloadUrl(shareId, file, shareToken), '_self')
}, },
// 共享文件预览 // 共享文件预览
publicPreview: function(fileId, shareId, shareToken) { publicPreview: function(file, shareId, shareToken) {
const url = this.publicPreviewUrl(fileId, shareId, shareToken) const url = this.publicPreviewUrl(file, shareId, shareToken)
window.open(url, '_blank') window.open(url, '_blank')
}, },
// 共享文件预览Url // 共享文件预览Url
publicPreviewUrl: function(fileId, shareId, shareToken) { publicPreviewUrl: function(file, shareId, shareToken) {
if (!shareToken) { if (!shareToken) {
shareToken = "none" 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) { publicPackageDownload: function(shareId, fileIds, shareToken) {
@ -76,7 +76,7 @@ export default {
if (!shareToken) { if (!shareToken) {
shareToken = "none" 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 // 共享文件打包下载Url
publicPackageDownloadUrl: function(shareId, fileIds, shareToken) { publicPackageDownloadUrl: function(shareId, fileIds, shareToken) {

View File

@ -1032,7 +1032,7 @@ export default {
return return
} }
// 打开文件 // 打开文件
fileConfig.publicPreview(row.id, this.shareId, this.$store.getters.shareToken) fileConfig.publicPreview(row, this.shareId, this.$store.getters.shareToken)
} }
}, },
/** /**