From ddd60a6a79dd7e359a9ab96dda2ebe94a1800db1 Mon Sep 17 00:00:00 2001
From: linyuchen <lin.yu.chen@foxmail.com>
Date: Sat, 20 Jan 2024 23:24:24 +0800
Subject: [PATCH] fix voice record type

---
 src/common/types.ts | 2 +-
 src/renderer.ts     | 5 +++--
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/common/types.ts b/src/common/types.ts
index fdd9b62..351f4a6 100644
--- a/src/common/types.ts
+++ b/src/common/types.ts
@@ -114,7 +114,7 @@ export type SendMessage = {
         text: string, // 纯文本
     }
 } | {
-    type: "image" | "voice",
+    type: "image" | "voice" | "record",
     file: string, // 本地路径
     data?: {
         file: string // 本地路径
diff --git a/src/renderer.ts b/src/renderer.ts
index 6a62807..24f018f 100644
--- a/src/renderer.ts
+++ b/src/renderer.ts
@@ -227,7 +227,7 @@ async function listenSendMessage(postData: PostDataSendMsg) {
                     message.content = `@${atMember.cardName || atMember.nick}`
                 } else if (message.type == "text") {
                     message.content = message.data?.text || message.content
-                } else if (message.type == "image" || message.type == "voice") {
+                } else if (message.type == "image" || message.type == "voice" || message.type == "record") {
                     // todo: 收到的应该是uri格式的,需要转成本地的, uri格式有三种,http, file, base64
                     let url = message.data?.file || message.file
                     let uri = new URL(url);
@@ -235,7 +235,8 @@ async function listenSendMessage(postData: PostDataSendMsg) {
                     if (message.type == "image") {
                         ext = ".png"
                     }
-                    if (message.type == "voice") {
+                    if (message.type == "voice" || message.type == "record") {
+                        message.type = "voice"
                         ext = ".amr"
                     }
                     let localFilePath = `${Date.now()}${ext}`