From bf711f2ad7a6702452bfb7bf8a173d1dc74424e8 Mon Sep 17 00:00:00 2001 From: greenjerry Date: Fri, 2 Feb 2024 13:58:06 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=AF=BC=E5=87=BAjson?= =?UTF-8?q?=E5=92=8Cmarkdown=E6=97=B6=E4=B8=AD=E6=96=87=E5=8F=8A=E5=85=B6?= =?UTF-8?q?=E4=BB=96utf8=E5=AD=97=E7=AC=A6=E4=B9=B1=E7=A0=81=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/global.d.ts | 1 + app/utils.ts | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/global.d.ts b/app/global.d.ts index e0a2c3f0686..31e2b6e8a84 100644 --- a/app/global.d.ts +++ b/app/global.d.ts @@ -19,6 +19,7 @@ declare interface Window { }; fs: { writeBinaryFile(path: string, data: Uint8Array): Promise; + writeTextFile(path: string, data: string): Promise; }; notification:{ requestPermission(): Promise; diff --git a/app/utils.ts b/app/utils.ts index ac7e80e7afd..06c0142bbe7 100644 --- a/app/utils.ts +++ b/app/utils.ts @@ -52,9 +52,9 @@ export async function downloadAs(text: string, filename: string) { if (result !== null) { try { - await window.__TAURI__.fs.writeBinaryFile( + await window.__TAURI__.fs.writeTextFile( result, - new Uint8Array([...text].map((c) => c.charCodeAt(0))) + text ); showToast(Locale.Download.Success); } catch (error) {