downloadFile(url: string, params: any, fileName = "video.mp4") {
instance({
url,
params,
method: "get",
responseType: "blob",
}).then((response) => {
const blob = new Blob([response.data], {
type: response.data.type,
});
const name = (response.headers["file-name"] as string) || fileName;
const link = document.createElement("a");
link.download = decodeURIComponent(name);
document.body.appendChild(link);
// <a href='http://www'/>
link.href = URL.createObjectURL(blob);
link.click();
document.body.removeChild(link);
// 浏览器释放地址栏
window.URL.revokeObjectURL(link.href);
});
},