From a8ce66d82e99532205600937d892a2be2d332da7 Mon Sep 17 00:00:00 2001 From: toesbieya <1647775459@qq.com> Date: Fri, 3 Jul 2020 10:43:05 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=96=87=E4=BB=B6=E9=A2=84?= =?UTF-8?q?=E8=A7=88=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vue/src/utils/file.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/vue/src/utils/file.js b/vue/src/utils/file.js index 8d39e04..9f3efad 100644 --- a/vue/src/utils/file.js +++ b/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)}`