修改:选择文件时将文件设为公共文件

This commit is contained in:
jmal 2021-02-19 11:45:49 +08:00
parent 782b1d6bcb
commit 2147b99c6b
3 changed files with 20 additions and 5 deletions

View File

@ -64,6 +64,14 @@ export default {
}) })
} }
}, },
// 将文件设为公共文件
setPublic: function(params) {
return request({
url: 'setPublic',
method: 'put',
params
})
},
// 删除 // 删除
delete: function(params) { delete: function(params) {
return request({ return request({

View File

@ -64,8 +64,9 @@
<script> <script>
import axios from 'axios' import axios from 'axios'
import fileConfig from "@/utils/file-config"; import fileApi from '@/api/file-api'
import SelectFile from "@/components/ShowFile/SelectFile"; import fileConfig from "@/utils/file-config"
import SelectFile from "@/components/ShowFile/SelectFile"
export default { export default {
name: 'UploadImageInput', name: 'UploadImageInput',
@ -124,8 +125,10 @@ export default {
input(value) { input(value) {
}, },
selectedFile(row) { selectedFile(row) {
this.currentValue = window.location.origin + fileConfig.previewUrl(this.$store.state.user.name, row, this.$store.getters.token) fileApi.setPublic({fileId: row.id}).then(() => {
this.change(this.currentValue) this.currentValue = window.location.origin + fileConfig.previewUrl(this.$store.state.user.name, row, undefined)
this.change(this.currentValue)
})
}, },
handleBeforeUpload(){ handleBeforeUpload(){
this.uploadState = 1 this.uploadState = 1

View File

@ -7,7 +7,11 @@ export default {
return window.location.origin + `${this.baseUrl}/webDAV/${username}` return window.location.origin + `${this.baseUrl}/webDAV/${username}`
}, },
previewUrl: function(username, file, token) { previewUrl: function(username, file, token) {
return `${this.baseUrl}/file/${username}${file.path}${file.name}?jmal-token=${token}` if (token) {
return `${this.baseUrl}/file/${username}${file.path}${file.name}?jmal-token=${token}`
} else {
return `${this.baseUrl}/file/${username}${file.path}${file.name}`
}
}, },
mardownPreviewUrl: function (path){ mardownPreviewUrl: function (path){
return window.location.origin + `${this.baseUrl}${path}` return window.location.origin + `${this.baseUrl}${path}`