Merge pull request #2 from Wxw-Gu/fix-issue-1

Fixes #1: 修复个人聊天界面和导出csv文件不显示名称问题
This commit is contained in:
qingmao
2026-01-04 15:57:10 +08:00
committed by GitHub
4 changed files with 28 additions and 8 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "wechatexplorer",
"version": "1.0.1",
"version": "1.0.2",
"description": "mac 版本获取微信聊天记录, AI群聊总结助手",
"keywords": [
"wechat",
+1 -3
View File
@@ -161,14 +161,12 @@ app.whenReady().then(() => {
return {
id: msg.mesLocalID || Math.random().toString(),
from: msg.mesDes === '1' ? 'user' : 'assistant', // 1 通常是接收到的,0 是发送的?需要验证。Swift 说:[1: "user", 0: "assistant"]
from: msg.mesDes === 1 ? 'user' : 'assistant', // 1 通常是接收到的,0 是发送的?需要验证。Swift 说:[1: "user", 0: "assistant"]
type: MSG_TYPE_DICT[msgType] || msg.messageType,
datetime: date.toLocaleString('zh-CN', { hour12: false }),
content: content,
isSender: msg.mesDes === '0',
img: img,
name: name
// 实际上让我们坚持我们观察到的:1=用户(其他人), 0=助手(我)
}
})
})
+1 -1
View File
@@ -13,7 +13,7 @@ export interface UserContact {
export interface WechatMessage {
mesLocalID: string
mesDes: string
mesDes: number
messageType: string
msgCreateTime: string
msgContent: string
+25 -3
View File
@@ -39,6 +39,7 @@ const ChatWindow: React.FC<ChatWindowProps> = ({
onRefresh,
onRefreshData
}) => {
const isGroupChat = contact?.type === 'group' || contact?.m_nsUsrName?.endsWith('@chatroom')
const messagesEndRef = useRef<HTMLDivElement>(null)
const imageContainerRef = useRef<HTMLDivElement>(null)
const [generatedImage, setGeneratedImage] = useState<string | null>(null)
@@ -115,11 +116,16 @@ const ChatWindow: React.FC<ChatWindowProps> = ({
// 昨天
const startOfYesterday = startOfDay - 86400000
return parsed >= startOfYesterday && parsed < startOfDay
} else {
} else if (days === 7) {
// 过去 7 天
const startOf7DaysAgo = startOfDay - 7 * 86400000
return parsed >= startOf7DaysAgo
} else if (days === 30) {
// 过去 30 天
const startOf30DaysAgo = startOfDay - 30 * 86400000
return parsed >= startOf30DaysAgo
}
return true
})
}
@@ -127,7 +133,15 @@ const ChatWindow: React.FC<ChatWindowProps> = ({
const csvContent = [
headers.join(','),
...filtered.map((m) => {
const content = m.content.replace(/"/g, '""').replace(/\n/g, ' ')
let prefix = ''
if (isGroupChat) {
prefix = m.name ? `${m.name}: ` : ''
} else {
const name = m.from === 'user' ? contact?.m_nsNickName || '未知' : '我'
prefix = `${name}: `
}
const fullContent = `${prefix}${m.content}`
const content = fullContent.replace(/"/g, '""').replace(/\n/g, ' ')
return `"${m.from}","${m.type}","${m.datetime}","${content}"`
})
].join('\n')
@@ -300,7 +314,12 @@ const ChatWindow: React.FC<ChatWindowProps> = ({
display: !showAvatar ? 'flex' : 'block'
}}
>
{msg.name && <div style={{ fontSize: 18 }}>{msg.name}: </div>}
{(msg.name || contact.m_nsNickName) && (
<div style={{ display: 'flex', fontSize: 18 }}>
{isGroupChat ? msg.name : msg.from === 'user' ? contact.m_nsNickName : '我'}
<span>{isGroupChat ? (msg.name ? ':' : '') : ':'} </span>
</div>
)}
<div
style={{
fontSize: 18,
@@ -367,6 +386,9 @@ const ChatWindow: React.FC<ChatWindowProps> = ({
<button className="toolbar-btn" onClick={() => handleExport(7)}>
📅 7
</button>
<button className="toolbar-btn" onClick={() => handleExport(30)}>
📅 30
</button>
<button className="toolbar-btn" onClick={() => setShowSettingsModal(true)}>
🤖 AI总结群聊
</button>