fix voice record type

This commit is contained in:
linyuchen 2024-01-20 23:24:24 +08:00
parent e4d8c5e72e
commit ddd60a6a79
2 changed files with 4 additions and 3 deletions

View File

@ -114,7 +114,7 @@ export type SendMessage = {
text: string, // 纯文本 text: string, // 纯文本
} }
} | { } | {
type: "image" | "voice", type: "image" | "voice" | "record",
file: string, // 本地路径 file: string, // 本地路径
data?: { data?: {
file: string // 本地路径 file: string // 本地路径

View File

@ -227,7 +227,7 @@ async function listenSendMessage(postData: PostDataSendMsg) {
message.content = `@${atMember.cardName || atMember.nick}` message.content = `@${atMember.cardName || atMember.nick}`
} else if (message.type == "text") { } else if (message.type == "text") {
message.content = message.data?.text || message.content 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 // todo: 收到的应该是uri格式的需要转成本地的, uri格式有三种http, file, base64
let url = message.data?.file || message.file let url = message.data?.file || message.file
let uri = new URL(url); let uri = new URL(url);
@ -235,7 +235,8 @@ async function listenSendMessage(postData: PostDataSendMsg) {
if (message.type == "image") { if (message.type == "image") {
ext = ".png" ext = ".png"
} }
if (message.type == "voice") { if (message.type == "voice" || message.type == "record") {
message.type = "voice"
ext = ".amr" ext = ".amr"
} }
let localFilePath = `${Date.now()}${ext}` let localFilePath = `${Date.now()}${ext}`