mirror of
https://github.com/certd/certd.git
synced 2026-04-24 04:17:25 +08:00
perf: ui 升级到antdv3.x
This commit is contained in:
@@ -1,40 +1,40 @@
|
||||
import { request } from './service'
|
||||
import _ from 'lodash-es'
|
||||
function arrayToMap (arr) {
|
||||
import { request } from "./service";
|
||||
import _ from "lodash-es";
|
||||
function arrayToMap(arr) {
|
||||
if (arr && arr instanceof Array) {
|
||||
const map = {}
|
||||
_.forEach(arr, item => {
|
||||
map[item.key] = item
|
||||
})
|
||||
return map
|
||||
const map = {};
|
||||
_.forEach(arr, (item) => {
|
||||
map[item.key] = item;
|
||||
});
|
||||
return map;
|
||||
}
|
||||
return arr
|
||||
return arr;
|
||||
}
|
||||
|
||||
function transfer (options) {
|
||||
options.accessProviders = arrayToMap(options.accessProviders)
|
||||
function transfer(options) {
|
||||
options.accessProviders = arrayToMap(options.accessProviders);
|
||||
}
|
||||
export default {
|
||||
exportsToZip (options) {
|
||||
transfer(options)
|
||||
exportsToZip(options) {
|
||||
transfer(options);
|
||||
return request({
|
||||
url: '/exports/toZip',
|
||||
url: "/exports/toZip",
|
||||
data: { options },
|
||||
method: 'post',
|
||||
responseType: 'blob' // 重点在于配置responseType: 'blob'
|
||||
}).then(res => {
|
||||
console.log('res', res)
|
||||
const filename = decodeURI(res.headers['content-disposition'].replace('attachment;filename=', '')) // 由后端设置下载文件名
|
||||
const blob = new Blob([res.data], { type: 'application/zip' })
|
||||
const a = document.createElement('a')
|
||||
const url = window.URL.createObjectURL(blob)
|
||||
a.href = url
|
||||
a.download = filename
|
||||
const body = document.getElementsByTagName('body')[0]
|
||||
body.appendChild(a)
|
||||
a.click()
|
||||
body.removeChild(a)
|
||||
window.URL.revokeObjectURL(url)
|
||||
})
|
||||
method: "post",
|
||||
responseType: "blob" // 重点在于配置responseType: 'blob'
|
||||
}).then((res) => {
|
||||
console.log("res", res);
|
||||
const filename = decodeURI(res.headers["content-disposition"].replace("attachment;filename=", "")); // 由后端设置下载文件名
|
||||
const blob = new Blob([res.data], { type: "application/zip" });
|
||||
const a = document.createElement("a");
|
||||
const url = window.URL.createObjectURL(blob);
|
||||
a.href = url;
|
||||
a.download = filename;
|
||||
const body = document.getElementsByTagName("body")[0];
|
||||
body.appendChild(a);
|
||||
a.click();
|
||||
body.removeChild(a);
|
||||
window.URL.revokeObjectURL(url);
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user