From 7c8cb43afdd76049154992ed0fe85f66957438be Mon Sep 17 00:00:00 2001 From: afan Date: Thu, 17 Apr 2025 16:38:04 +0800 Subject: [PATCH] =?UTF-8?q?aitxt=E6=A0=BC=E5=BC=8F=E5=AF=BC=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/chatlog/app.go | 2 +- internal/chatlog/http/route.go | 9 ++++++++- internal/chatlog/manager.go | 5 +++-- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/internal/chatlog/app.go b/internal/chatlog/app.go index afd3c6e..4ffb448 100644 --- a/internal/chatlog/app.go +++ b/internal/chatlog/app.go @@ -962,7 +962,7 @@ func (a *App) exportChat(talker, displayName string) { a.mainPages.RemovePage("modal") a.mainPages.SwitchToPage("main") }) - // 为模态框添加输入处理函数,确保回车键可以关闭对话框 + modal.SetInputCapture(func(event *tcell.EventKey) *tcell.EventKey { if event.Key() == tcell.KeyEnter { a.mainPages.RemovePage("modal") diff --git a/internal/chatlog/http/route.go b/internal/chatlog/http/route.go index d0ac032..bbb0f43 100644 --- a/internal/chatlog/http/route.go +++ b/internal/chatlog/http/route.go @@ -141,8 +141,15 @@ func (s *Service) GetChatlog(c *gin.Context) { // 添加日期分隔线 c.Writer.WriteString("\n********************" + date + "********************\n\n") - // 输出该日期下的所有消息 for _, m := range msgs { + senderName := m.SenderName + if m.IsSelf { + senderName = "我" + } else if senderName == "" { + senderName = m.Sender + } + + c.Writer.WriteString(senderName + ": ") c.Writer.WriteString(m.PlainTextContent()) c.Writer.WriteString("\n\n") } diff --git a/internal/chatlog/manager.go b/internal/chatlog/manager.go index 0474ca4..bfb40ae 100644 --- a/internal/chatlog/manager.go +++ b/internal/chatlog/manager.go @@ -417,8 +417,9 @@ func (m *Manager) ExportChatlogTXT(talker string, timeRange string, outputPath s senderName = msg.Sender } - f.WriteString(senderName + " ") - f.WriteString(msg.Time.Format("15:04:05") + "\n") + //f.WriteString(senderName + " ") + //f.WriteString(msg.Time.Format("15:04:05") + "\n") + f.WriteString(senderName + ": ") // 设置消息内容中可能需要的主机信息 msg.SetContent("host", host)