|
|
|
@ -35,6 +35,7 @@ |
|
|
|
@resend="onResendMessage" |
|
|
|
@delete="deleteMessage" |
|
|
|
@recall="recallMessage" |
|
|
|
@translate="translateMessage" |
|
|
|
> |
|
|
|
</chat-message-item> |
|
|
|
</div> |
|
|
|
@ -728,6 +729,27 @@ export default { |
|
|
|
}); |
|
|
|
}); |
|
|
|
}, |
|
|
|
async translateMessage(msgInfo) { |
|
|
|
try { |
|
|
|
// 调用翻译API |
|
|
|
const res = await this.getTranslateText(msgInfo.content); |
|
|
|
if (res) { |
|
|
|
// 找到chatStore中的消息并更新 |
|
|
|
let chat = this.chatStore.findChat(this.chat); |
|
|
|
let message = this.chatStore.findMessage(chat, msgInfo); |
|
|
|
if (message) { |
|
|
|
// 直接更新消息对象的content属性 |
|
|
|
message.content = res; |
|
|
|
// 标记需要保存 |
|
|
|
chat.stored = false; |
|
|
|
this.chatStore.saveToStorage(); |
|
|
|
this.$message.success("翻译成功"); |
|
|
|
} |
|
|
|
} |
|
|
|
} catch (error) { |
|
|
|
this.$message.error("翻译失败: " + (error.message || "未知错误")); |
|
|
|
} |
|
|
|
}, |
|
|
|
readedMessage() { |
|
|
|
if (this.chat.unreadCount > 0) { |
|
|
|
if (this.isGroup) { |
|
|
|
|