后端代码
 
@PostMapping("/packetLoss/linearInterpolate")public ResponseEntity<InputStreamResource> linearInterpolate(@RequestParam String url,@RequestBody RecordLinearInterpolateDTO recordLinearInterpolateDTO){InputStream inputStream = flightRecordService.linearInterpolate(url, recordLinearInterpolateDTO);HttpHeaders headers = new HttpHeaders();headers.add("Content-Disposition", "attachment; filename=data.csv");  headers.add("Content-Type", "text/csv;charset=UTF-8");  return ResponseEntity.ok().headers(headers).body(new InputStreamResource(inputStream));}
 
前端
 
_axios.post("/flightRecord/packetLoss/linearInterpolate", {lossIndexes: analysisResult.lossIndexes}, {params: {url: analysisFileUrl.value},responseType: "blob"}).then(res => {const blob = new Blob([res.data]);const url = window.URL.createObjectURL(blob);const link = document.createElement('a');link.href = url;link.setAttribute('download', 'analysis_result.csv');  document.body.appendChild(link);link.click();window.URL.revokeObjectURL(url);link.remove();ElMessage.success("分析完成");}).catch(error => {ElMessage.error("分析失败")}).finally(() => {interpolationLoading.value = false})