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)