diff --git a/src/views/realTimeMonitor/components/carouselChart.vue b/src/views/realTimeMonitor/components/carouselChart.vue index 212bbb6..2b8be01 100644 --- a/src/views/realTimeMonitor/components/carouselChart.vue +++ b/src/views/realTimeMonitor/components/carouselChart.vue @@ -2,6 +2,7 @@
{{ radioPx }} +
{ - const canvas = document.createElement("canvas"); - canvas.width = image.width; - canvas.height = image.height; - const ctx = canvas.getContext("2d"); - ctx.drawImage(image, 0, 0, image.width, image.height); - canvas.toBlob((blob) => { - const url = URL.createObjectURL(blob); - this.download(url, name); - // 用完释放URL对象 - URL.revokeObjectURL(url); - }); - }; - }, - download(href, name) { - const eleLink = document.createElement("a"); - eleLink.download = name; - eleLink.href = href; - eleLink.click(); - eleLink.remove(); + async downLoadPic(path, name) { + const imgUrl = path; + const response = await fetch(imgUrl); + const blob = await response.blob(); + // 创建下载链接 + const url = window.URL.createObjectURL(blob); + const link = document.createElement("a"); + link.href = url; + link.download = name; + document.body.appendChild(link); + link.click(); + document.body.removeChild(link); + // 释放 Blob URL + window.URL.revokeObjectURL(url); }, + // downLoadPic(url, name) { + // const image = new Image(); + // image.setAttribute("crossOrigin", "anonymous"); + // image.src = url; + // image.onload = () => { + // const canvas = document.createElement("canvas"); + // canvas.width = image.width; + // canvas.height = image.height; + // const ctx = canvas.getContext("2d"); + // ctx.drawImage(image, 0, 0, image.width, image.height); + // canvas.toBlob((blob) => { + // const url = URL.createObjectURL(blob); + // this.download(url, name); + // // 用完释放URL对象 + // URL.revokeObjectURL(url); + // }); + // }; + // }, + // download(href, name) { + // const eleLink = document.createElement("a"); + // eleLink.download = name; + // eleLink.href = href; + // eleLink.click(); + // eleLink.remove(); + // }, //获取线缆绘制显示 getPointList(data) { getCoordinate({ diff --git a/src/views/realTimeMonitor/components/parameterArea.vue b/src/views/realTimeMonitor/components/parameterArea.vue index 904b6a1..5fee846 100644 --- a/src/views/realTimeMonitor/components/parameterArea.vue +++ b/src/views/realTimeMonitor/components/parameterArea.vue @@ -1,6 +1,19 @@