bl-common-vue3 3.8.130 → 3.8.131
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -511,23 +511,28 @@ export default defineComponent({
|
|
|
511
511
|
message.error(t('AttachmentInfo.index.559728-10'));
|
|
512
512
|
return;
|
|
513
513
|
}
|
|
514
|
-
|
|
515
|
-
|
|
514
|
+
try {
|
|
515
|
+
const response = await fetch(url);
|
|
516
|
+
if (!response.ok) {
|
|
517
|
+
message.error(t('common.action.fail'));
|
|
518
|
+
return;
|
|
519
|
+
}
|
|
520
|
+
const blob = await response.blob();
|
|
521
|
+
const downloadUrl = window.URL.createObjectURL(blob);
|
|
522
|
+
|
|
523
|
+
const a = document.createElement('a');
|
|
524
|
+
a.href = downloadUrl;
|
|
525
|
+
a.setAttribute('download', name || url); // 设置下载的文件名
|
|
526
|
+
document.body.appendChild(a);
|
|
527
|
+
a.click();
|
|
528
|
+
document.body.removeChild(a);
|
|
529
|
+
|
|
530
|
+
// 释放 URL 对象
|
|
531
|
+
window.URL.revokeObjectURL(downloadUrl);
|
|
532
|
+
} catch (_) {
|
|
533
|
+
// 网络、跨域或文件读取失败也需明确反馈,不能留下未处理的下载异常。
|
|
516
534
|
message.error(t('common.action.fail'));
|
|
517
|
-
return;
|
|
518
535
|
}
|
|
519
|
-
const blob = await response.blob();
|
|
520
|
-
const downloadUrl = window.URL.createObjectURL(blob);
|
|
521
|
-
|
|
522
|
-
const a = document.createElement('a');
|
|
523
|
-
a.href = downloadUrl;
|
|
524
|
-
a.setAttribute('download', name || url); // 设置下载的文件名
|
|
525
|
-
document.body.appendChild(a);
|
|
526
|
-
a.click();
|
|
527
|
-
document.body.removeChild(a);
|
|
528
|
-
|
|
529
|
-
// 释放 URL 对象
|
|
530
|
-
window.URL.revokeObjectURL(downloadUrl);
|
|
531
536
|
};
|
|
532
537
|
|
|
533
538
|
// 删除文件
|