改进:文件访问添加鉴权
This commit is contained in:
parent
85df20b775
commit
782b1d6bcb
@ -93,7 +93,7 @@
|
||||
if(selectImg.id){
|
||||
this.loading = true
|
||||
this.cropper.reset()
|
||||
let url = fileConfig.previewUrl(this.$store.state.user.name, selectImg) + '?o=crop&w=1024'
|
||||
let url = fileConfig.previewUrl(this.$store.state.user.name, selectImg, this.$store.getters.token) + '&o=crop&w=1024'
|
||||
this.sourceImg = url
|
||||
this.cropper.replace(url)
|
||||
this.loading = false
|
||||
|
||||
@ -2755,7 +2755,7 @@ export default {
|
||||
fileConfig.packageDownload(fileIds, this.$store.state.user.token)
|
||||
return
|
||||
}
|
||||
fileConfig.download(this.$store.state.user.name, this.rowContextData)
|
||||
fileConfig.download(this.$store.state.user.name, this.rowContextData, this.$store.getters.token)
|
||||
} else {
|
||||
this.$message({
|
||||
message: '所选文件为空',
|
||||
@ -2980,7 +2980,7 @@ export default {
|
||||
if (window.location.port.length > 0) {
|
||||
host = window.location.host.substring(0, window.location.host.length - window.location.port.length - 1)
|
||||
}
|
||||
fileConfig.preview(this.$store.state.user.name, row)
|
||||
fileConfig.preview(this.$store.state.user.name, row, this.$store.getters.token)
|
||||
return
|
||||
}
|
||||
if (suffix.compressedFile.includes(row.suffix)) {
|
||||
@ -3007,7 +3007,7 @@ export default {
|
||||
this.notPreviewDialogVisible = false
|
||||
},
|
||||
downLaod(file) {
|
||||
fileConfig.download(this.$store.state.user.name, file)
|
||||
fileConfig.download(this.$store.state.user.name, file, this.$store.getters.token)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@ -124,7 +124,7 @@ export default {
|
||||
input(value) {
|
||||
},
|
||||
selectedFile(row) {
|
||||
this.currentValue = window.location.origin + fileConfig.previewUrl(this.$store.state.user.name, row)
|
||||
this.currentValue = window.location.origin + fileConfig.previewUrl(this.$store.state.user.name, row, this.$store.getters.token)
|
||||
this.change(this.currentValue)
|
||||
},
|
||||
handleBeforeUpload(){
|
||||
|
||||
@ -49,7 +49,7 @@ export default {
|
||||
pic.addEventListener('click', this.onPicClick);
|
||||
Bus.$on('onAddAudio',(newFile, audioCoverUrl) => {
|
||||
this.show = true
|
||||
let url = fileConfig.previewUrl(this.$store.state.user.name, newFile)
|
||||
let url = fileConfig.previewUrl(this.$store.state.user.name, newFile, this.$store.getters.token)
|
||||
console.log(url)
|
||||
if(!this.$store.state.user.token){
|
||||
url = fileConfig.publicPreviewUrl(newFile.id);
|
||||
|
||||
@ -89,7 +89,7 @@
|
||||
this.fileList.forEach((element,index) => {
|
||||
if(index < findIndex + 5 && index > findIndex - 5 ) {
|
||||
if(!element.isFolder && element.contentType.startsWith('image')){
|
||||
let url = fileConfig.previewUrl(this.$store.state.user.name, element)
|
||||
let url = fileConfig.previewUrl(this.$store.state.user.name, element, this.$store.getters.token)
|
||||
if(this.shareId){
|
||||
url = fileConfig.publicPreviewUrl(element.id);
|
||||
}
|
||||
|
||||
@ -99,7 +99,7 @@ export default {
|
||||
watch: {
|
||||
status: function(visible){
|
||||
if(visible){
|
||||
let url = fileConfig.previewUrl(this.$store.state.user.name, this.file)
|
||||
let url = fileConfig.previewUrl(this.$store.state.user.name, this.file, this.$store.getters.token)
|
||||
if(this.shareId){
|
||||
url = fileConfig.publicPreviewUrl(this.file.id);
|
||||
}
|
||||
|
||||
@ -6,27 +6,26 @@ export default {
|
||||
webDAVUrl: function(username) {
|
||||
return window.location.origin + `${this.baseUrl}/webDAV/${username}`
|
||||
},
|
||||
previewUrl: function(username, file) {
|
||||
return `${this.baseUrl}/file/${username}${file.path}${file.name}`
|
||||
previewUrl: function(username, file, token) {
|
||||
return `${this.baseUrl}/file/${username}${file.path}${file.name}?jmal-token=${token}`
|
||||
},
|
||||
mardownPreviewUrl: function (path){
|
||||
return window.location.origin + `${this.baseUrl}${path}`
|
||||
},
|
||||
publicPreviewUrl: function(fileIds) {
|
||||
return `${this.baseUrl}/public/preview/${fileIds}`
|
||||
publicPreviewUrl: function(fileId) {
|
||||
return `${this.baseUrl}/public/preview/${fileId}`
|
||||
},
|
||||
preview: function(username, file) {
|
||||
const url = this.previewUrl(username, file)
|
||||
console.log(url)
|
||||
preview: function(username, file, token) {
|
||||
const url = this.previewUrl(username, file, token)
|
||||
window.open(url, '_blank')
|
||||
},
|
||||
publicPreview: function(fileIds) {
|
||||
const url = this.publicPreviewUrl(fileIds)
|
||||
window.open(url, '_blank')
|
||||
},
|
||||
download: function(username, file) {
|
||||
download: function(username, file, token) {
|
||||
fileApi.isAllowDownload().then(() => {
|
||||
let url = `${this.baseUrl}/file/${username}${file.path}${file.name}?o=download`
|
||||
let url = `${this.baseUrl}/file/${username}${file.path}${file.name}?jmal-token=${token}&o=download`
|
||||
window.open(url, '_self')
|
||||
})
|
||||
},
|
||||
|
||||
@ -986,7 +986,7 @@
|
||||
this.$router.push(`/public/articles/article?mark=${row.id}`)
|
||||
}else{
|
||||
// 打开文件
|
||||
fileConfig.preview(this.$store.state.user.token, row)
|
||||
fileConfig.preview(this.$store.state.user.token, row, this.$store.getters.token)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user