diff --git a/src/views/face/Single.vue b/src/views/face/Single.vue
index 10e147233..71481765a 100644
--- a/src/views/face/Single.vue
+++ b/src/views/face/Single.vue
@@ -122,7 +122,7 @@
版本 : {{ item.created_at }}
备注 : {{ item.describe }}
- 下载
+ 下载
@@ -448,11 +448,51 @@ export default {
this.loading = false;
});
},
- getDownUrl(uuid) {
+ getDownUrl(uuid, filename) {
getDownUrl(this.id, uuid).then((res) => {
- window.location.href = resolveImagePath(res.data.data?.url);
+ // window.location.href = resolveImagePath(res.data.data?.url);
+ this.downloadfile(res.data.data?.url, filename)
});
},
+ downloadfile(url, filename) {
+ this.getBlob(url).then((blob) => {
+ this.saveAs(blob, filename);
+ });
+ },
+ getBlob(url) {
+ return new Promise((resolve) => {
+ const xhr = new XMLHttpRequest();
+
+ xhr.open('GET', url, true);
+ xhr.responseType = 'blob';
+ xhr.onload = () => {
+ if (xhr.status === 200) {
+ resolve(xhr.response);
+ }
+ };
+
+ xhr.send();
+ });
+ },
+ saveAs(blob, filename) {
+ if (window.navigator.msSaveOrOpenBlob) {
+ navigator.msSaveBlob(blob, filename);
+ } else {
+ const link = document.createElement('a');
+ const body = document.querySelector('body');
+
+ link.href = window.URL.createObjectURL(blob);
+ link.download = filename;
+ // fix Firefox
+ link.style.display = 'none';
+ body.appendChild(link);
+
+ link.click();
+ body.removeChild(link);
+
+ window.URL.revokeObjectURL(link.href);
+ }
+ },
downloadAll() {
const urlArr = []
this.downFileList.forEach(item => {
@@ -463,7 +503,7 @@ export default {
p.then(arr => {
downloadFiles = arr.map((item, index) => {
return {
- name: this.downFileList[index].name + '.jx3dat',
+ name: this.downFileList[index].name,
url: item.data.data?.url
}
})