修复文件预览的问题

master
toesbieya 6 years ago
parent 1ad33332f5
commit a8ce66d82e
  1. 6
      vue/src/utils/file.js

@ -1,6 +1,7 @@
import request from '@/config/request'
import {attachmentUploadUrl, attachmentPrefix, filePreviewPrefix} from '@/config'
import {isEmpty, timeFormat} from "@/utils"
import {isTxt} from "@/utils/validate"
const defaultOptions = {
headers: {"Content-Type": "multipart/form-data"},
@ -14,7 +15,10 @@ const defaultOptions = {
//文件预览
export function preview(url) {
url = `${url}&fullfilename=${url.replace(attachmentPrefix, '')}`
if (isTxt(url)) return window.open(url)
const connectChar = url.includes('?') ? '&' : '?'
url = url + connectChar + 'fullfilename=' + url.replace(attachmentPrefix, '')
const anchor = document.createElement('a')
anchor.style.visibility = 'hidden'
anchor.href = `${filePreviewPrefix}/onlinePreview?url=${encodeURIComponent(url)}`

Loading…
Cancel
Save