From d67d7affc36e539138f6148b7f7e89e5dc8ffea2 Mon Sep 17 00:00:00 2001 From: Zhufu <1176354795@qq.com> Date: Wed, 21 Aug 2024 10:59:41 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AF=A6=E6=83=85PDF=E9=99=84=E4=BB=B6?= =?UTF-8?q?=E7=82=B9=E5=87=BB=E5=90=8E=E4=B8=8D=E4=B8=8B=E8=BD=BD=E5=9C=A8?= =?UTF-8?q?=E6=B5=8F=E8=A7=88=E5=99=A8=E4=B8=AD=E8=BF=9B=E8=A1=8C=E9=A2=84?= =?UTF-8?q?=E8=A7=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MapList/ShowInfoModal/index.vue | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/views/demo/tiankongdi/curbspotcity/MapList/ShowInfoModal/index.vue b/src/views/demo/tiankongdi/curbspotcity/MapList/ShowInfoModal/index.vue index ce77917b..f5f87534 100644 --- a/src/views/demo/tiankongdi/curbspotcity/MapList/ShowInfoModal/index.vue +++ b/src/views/demo/tiankongdi/curbspotcity/MapList/ShowInfoModal/index.vue @@ -347,6 +347,7 @@ import { getGeom } from '@/api/sys/layerManagement'; import {getLoadCaseImgList} from '@/api/tiankongdi' import { useMessage } from '@/hooks/web/useMessage'; + import axios from 'axios'; const { createMessage } = useMessage(); import Icon from '@/components/Icon/Icon.vue'; import { getAppEnvConfig } from '@/utils/env'; @@ -654,7 +655,27 @@ } } const downLoadFile = (url) => { - window.open(`${VITE_GLOB_INFO_IMAGE_URL}/${url}`, 'mozillaTab'); + if(url.indexOf('.pdf') !== -1){ + axios({ + method: 'get', + url: `${VITE_GLOB_INFO_IMAGE_URL}/${url}`, + responseType: 'blob', + headers: { + 'Content-Disposition': 'inline', + } + }) + .then(response => { + let blob = new Blob([response.data], {type: 'application/pdf'}); + let url = window.URL.createObjectURL(blob) + window.open(url); + }) + .catch(error => { + console.error(error); + }); + }else{ + window.open(`${VITE_GLOB_INFO_IMAGE_URL}/${url}`, '_blank'); + } + }; const getContainer = () => { return document.getElementById('info-container');