[bug] - 预览文件 名字相同时,文件信息不对

This commit is contained in:
fengchenchen
2022-08-19 14:45:23 +08:00
parent d8f0e88e8f
commit 143109f589
3 changed files with 19 additions and 5 deletions
+6 -1
View File
@@ -136,9 +136,14 @@
const fileObj = await this.getFileInfo(arr[a])
// 获取图片路径
const url = getFileAccessHttpUrl(fileObj.url)
const fileName = (fileObj || {}).fileName
const fileNameNotType = fileName.substring(0, fileName.lastIndexOf('.'))
const previewUrl = (fileObj || {}).url || ''
const previewName = previewUrl.substring(previewUrl.lastIndexOf(fileNameNotType))
fileList.push({
uid: uidGenerator(),
name: (fileObj || {}).fileName,
previewName,
status: 'done',
url: url,
response: {
@@ -225,7 +230,7 @@
// 预览
handlePreview(file) {
if (file && file.url) {
var fileFullUrl = `${window._CONFIG['domianWebSocketURL']}/sys/common/download/${file.response.result.id}?token=${Vue.ls.get(ACCESS_TOKEN)}&fullfilename=${file.name}`
var fileFullUrl = `${window._CONFIG['domianWebSocketURL']}/sys/common/download/${file.response.result.id}?token=${Vue.ls.get(ACCESS_TOKEN)}&fullfilename=${file.previewName || file.name}`
// let url = `${window._CONFIG['onlinePreviewDomainURL']}?url=${encodeURIComponent(Base64.encode(fileFullUrl))}`
let url = `${window._CONFIG['onlinePreviewDomainURL']}?url=${encodeURIComponent(fileFullUrl)}`
window.open(url)
+7 -2
View File
@@ -231,11 +231,16 @@ export default {
} else {
const fileObj = await this.getFileInfo(arr[a])
const url = getFileAccessHttpUrl(arr[a])
const fileName = (fileObj || {}).fileName
const fileNameNotType = fileName.substring(0, fileName.lastIndexOf('.'))
const previewUrl = (fileObj || {}).url || ''
const previewName = previewUrl.substring(previewUrl.lastIndexOf(fileNameNotType))
fileList.push({
uid: uidGenerator(),
name: (fileObj || {}).fileName,
status: 'done',
url: url,
previewName,
response: {
status: 'history',
message: arr[a],
@@ -383,7 +388,7 @@ export default {
}
// eslint-disable-next-line no-unreachable
if (file && file.url) {
const fileFullUrl = `${window._CONFIG['domianWebSocketURL']}/sys/common/download/${file.response.result.id}?token=${Vue.ls.get(ACCESS_TOKEN)}&fullfilename=${file.name}`
const fileFullUrl = `${window._CONFIG['domianWebSocketURL']}/sys/common/download/${file.response.result.id}?token=${Vue.ls.get(ACCESS_TOKEN)}&fullfilename=${file.previewName}`
let url = `${window._CONFIG['onlinePreviewDomainURL']}?url=${encodeURIComponent(fileFullUrl)}`
// let url = `${window._CONFIG['onlinePreviewDomainURL']}?url=${encodeURIComponent(fileFullUrl)}`
window.open(url)
@@ -437,7 +442,7 @@ export default {
*/
myPreview(file) {
if (file && file.url) {
const fileFullUrl = `${window._CONFIG['domianWebSocketURL']}/sys/common/download/${file.response.result.id}?token=${Vue.ls.get(ACCESS_TOKEN)}&fullfilename=${file.name}`
const fileFullUrl = `${window._CONFIG['domianWebSocketURL']}/sys/common/download/${file.response.result.id}?token=${Vue.ls.get(ACCESS_TOKEN)}&fullfilename=${file.previewName}`
let url = `${window._CONFIG['onlinePreviewDomainURL']}?url=${encodeURIComponent(fileFullUrl)}`
// let url = `${window._CONFIG['onlinePreviewDomainURL']}?url=${encodeURIComponent(fileFullUrl)}`
window.open(url)
+6 -2
View File
@@ -70,7 +70,11 @@ export default {
for (let i = 0; i < arr.length; i++) {
let fileObj = {}
fileObj = await this.getFileInfo(arr[i])
fileList.push({id: fileObj.id, name: fileObj.fileName})
const fileName = (fileObj || {}).fileName
const fileNameNotType = fileName.substring(0, fileName.lastIndexOf('.'))
const previewUrl = (fileObj || {}).url || ''
const previewName = previewUrl.substring(previewUrl.lastIndexOf(fileNameNotType))
fileList.push({id: fileObj.id, name: fileObj.fileName, previewName})
}
this.fileList = [...fileList]
}else {
@@ -83,7 +87,7 @@ export default {
},
handlePreview(file) {
if (file && file.id) {
const fileFullUrl = `${window._CONFIG['domianWebSocketURL']}/sys/common/download/${file.id}?token=${Vue.ls.get(ACCESS_TOKEN)}&fullfilename=${file.name}`
const fileFullUrl = `${window._CONFIG['domianWebSocketURL']}/sys/common/download/${file.id}?token=${Vue.ls.get(ACCESS_TOKEN)}&fullfilename=${file.previewName}`
let url = `${window._CONFIG['onlinePreviewDomainURL']}?url=${encodeURIComponent(fileFullUrl)}`
// let url = `${window._CONFIG['onlinePreviewDomainURL']}?url=${encodeURIComponent(fileFullUrl)}`
window.open(url)