| | |
| | | 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'; |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | 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); |