From 1910e9f27373b8b4da75f076762025ceb3419965 Mon Sep 17 00:00:00 2001
From: zhengyiming <540361168@qq.com>
Date: 星期四, 12 六月 2025 15:40:50 +0800
Subject: [PATCH] fix: 暂时隐藏电信充值通道
---
apps/taro/src/utils/file.ts | 35 +++++++++++++++++++++++++++++++++++
1 files changed, 35 insertions(+), 0 deletions(-)
diff --git a/apps/taro/src/utils/file.ts b/apps/taro/src/utils/file.ts
index 34a5b36..c959ae4 100644
--- a/apps/taro/src/utils/file.ts
+++ b/apps/taro/src/utils/file.ts
@@ -86,3 +86,38 @@
return fileName;
});
}
+
+export function downloadBase64File(base64Data: string, filename: string) {
+ // 灏哹ase64鏁版嵁鍒嗗壊锛岃幏鍙杕ime-type
+ const [, mime, b64data] = base64Data.match(/^data:([^;]+);base64,(.+)$/);
+
+ // 瑙g爜base64鏁版嵁
+ const byteString = atob(b64data);
+ const arrayBuffer = new ArrayBuffer(byteString.length);
+ const intArray = new Uint8Array(arrayBuffer);
+
+ for (let i = 0; i < byteString.length; i++) {
+ intArray[i] = byteString.charCodeAt(i);
+ }
+
+ // 鍒涘缓Blob瀵硅薄
+ const blob = new Blob([intArray], { type: mime });
+
+ //@ts-ignore
+ if (typeof navigator !== 'undefined' && navigator.msSaveOrOpenBlob) {
+ //@ts-ignore 鍏煎IE
+ navigator.msSaveOrOpenBlob(blob, filename);
+ } else {
+ // 鍒涘缓涓�涓复鏃剁殑a鏍囩鐢ㄤ簬瑙﹀彂涓嬭浇
+ const a = document.createElement('a');
+ const url = window.URL.createObjectURL(blob);
+ a.href = url;
+ a.download = filename; // 璁剧疆涓嬭浇鍚庣殑鏂囦欢鍚�
+ document.body.appendChild(a);
+ a.click(); // 瑙﹀彂涓嬭浇
+ document.body.removeChild(a);
+ setTimeout(() => {
+ window.URL.revokeObjectURL(url); // 娓呴櫎鍒涘缓鐨勫璞RL
+ }, 0);
+ }
+}
--
Gitblit v1.9.1