export function userPrizeListDownload(
params: Partial<UserPrizeList>,
) {
return requestLotteryApi(`/xxx/download`, {
params,
responseType: 'arrayBuffer', //這部分指定了響應的型別為
arrayBuffer
,表示希望以二進位制資料的形式接收響應。 });
}
const prizeListDownloadData = await userPrizeListDownload( newCurrentParams, );
// type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
const blob = new Blob([prizeListDownloadData], { type: 'application/csv', }); const link = document.createElement('a'); // 下載後的檔名 link.download = 'xxx.xlsx'; link.href = URL.createObjectURL(blob); document.body.appendChild(link); link.click(); //釋放URL物件 URL.revokeObjectURL(link.href); document.body.removeChild(link); message.success('成功');