wupengfei
2025-04-15 7f268bea057e788824bdf290275342d0980cbaeb
src/utils/common/download.ts
@@ -1,5 +1,5 @@
import { format } from '@/utils';
import { BoleRegExp, FILEMIME } from '@bole-core/core';
import { BoleRegExp, FILEMIME, downloadFileByUrl as _downloadFileByUrl } from '@bole-core/core';
import { saveAs } from 'file-saver';
import JSZip from 'jszip';
@@ -29,18 +29,9 @@
  }
}
export function downloadFileByUrl(fileUrl, fileName?: string) {
  //const suffix = /\.([0-9a-z]+)(?:[\?#]|$)/i.exec(fileUrl)[1];
  const suffix = /\.([0-9a-z]+)(?:[#]|$)/i.exec(fileUrl)[1];
  let name = fileName ? fileName : fileUrl.replace(BoleRegExp.RegFileName, '$2');
  name += `.${suffix}`;
  saveAs(fileUrl, name);
export function downloadFileByUrl(fileUrl: string, fileName?: string) {
  _downloadFileByUrl(fileUrl, fileName);
  return;
  // if (/pdf/gi.test(suffix)) {
  //   handlePdfLink(fileUrl, name);
  // } else {
  //   handleFileDownload(fileUrl, name);
  // }
}
export const handleFileSaver = (file, name) => {
  saveAs(file, name);