发起请求参数
。
return await request<Record<string, any>>(`${apiUrl}`, {
method: 'POST',
data: {something},
responseType: 'blob', // 必填
});
接受返回数据data
。
//发起请求
const data = await post(param);
// 处理返回数据
const reader = new FileReader();
reader.readAsArrayBuffer(data);
reader.onload = (e) => {
const result = e?.target?.result || '';
const blob = new Blob([result], { type: data.type });
const url = URL.createObjectURL(blob);
// 将文件下载下来
const link = document.createElement('a');
link.href = url;
link.setAttribute('download', `${playId}.qplay`);
link.style.display = 'none';
document.getElementsByTagName('link');
link.click();
};