From 0f0d87ffbe149d47342d2bf5d5e9ae6ce130c901 Mon Sep 17 00:00:00 2001 From: Surpriseplus <845948745@qq.com> Date: 星期四, 20 十月 2022 09:44:05 +0800 Subject: [PATCH] 综合展示 --- public/SmartEarthSDK/Workers/FileSaver.js | 19 +++++++++++-------- 1 files changed, 11 insertions(+), 8 deletions(-) diff --git a/public/SmartEarthSDK/Workers/FileSaver.js b/public/SmartEarthSDK/Workers/FileSaver.js index b23314e..dcf6cd2 100644 --- a/public/SmartEarthSDK/Workers/FileSaver.js +++ b/public/SmartEarthSDK/Workers/FileSaver.js @@ -142,12 +142,11 @@ : function saveAs(blob, name, opts, popup) { // Open a popup immediately do go around popup blocker // Mostly only available on user interaction and the fileReader is async so... - popup = popup || open('', '_blank'); - - if (popup) { - popup.document.title = popup.document.body.innerText = 'downloading...'; - } - + popup = popup + // || open('', '_blank'); + // if (popup) { + // popup.document.title = popup.document.body.innerText = 'downloading...'; + // } if (typeof blob === 'string') return download(blob, name, opts); var force = blob.type === 'application/octet-stream'; @@ -162,11 +161,15 @@ reader.onloadend = function () { var url = reader.result; url = isChromeIOS ? url : url.replace(/^data:[^;]*;/, 'data:attachment/file;'); - if (popup) popup.location.href = url;else location = url; + // if (popup) popup.location.href = url;else location = url; + let triggerDownload = document.createElement("a"); + triggerDownload.download = name; + triggerDownload.href = url; + triggerDownload.click(); popup = null; // reverse-tabnabbing #460 }; - reader.readAsDataURL(blob); + } else { var URL = _global.URL || _global.webkitURL; var url = URL.createObjectURL(blob); -- Gitblit v1.9.3