Kaynağa Gözat

修复导出json和markdown时中文及其他utf8字符乱码问题

greenjerry 1 yıl önce
ebeveyn
işleme
bf711f2ad7
2 değiştirilmiş dosya ile 3 ekleme ve 2 silme
  1. 1 0
      app/global.d.ts
  2. 2 2
      app/utils.ts

+ 1 - 0
app/global.d.ts

@@ -19,6 +19,7 @@ declare interface Window {
     };
     fs: {
       writeBinaryFile(path: string, data: Uint8Array): Promise<void>;
+      writeTextFile(path: string, data: string): Promise<void>;
     };
     notification:{
       requestPermission(): Promise<Permission>;

+ 2 - 2
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) {