diff --git a/electron/services/httpService.ts b/electron/services/httpService.ts
index 863ed80..5715486 100644
--- a/electron/services/httpService.ts
+++ b/electron/services/httpService.ts
@@ -2045,6 +2045,12 @@ class HttpService {
* 获取消息内容
*/
private getMessageContent(msg: Message): string | null {
+ const normalizeTextContent = (value: string | null | undefined): string | null => {
+ const text = String(value || '')
+ if (!text) return null
+ return text.replace(/^[\s]*([a-zA-Z0-9_@-]+):(?!\/\/)(?:\s*(?:\r?\n|
)\s*|\s*)/i, '').trim()
+ }
+
if (msg.localType === 49) {
return this.getType49Content(msg)
}
@@ -2057,7 +2063,7 @@ class HttpService {
// 根据类型返回占位符
switch (msg.localType) {
case 1:
- return msg.rawContent || null
+ return normalizeTextContent(msg.parsedContent || msg.rawContent)
case 3:
return '[图片]'
case 34:
@@ -2073,7 +2079,7 @@ class HttpService {
case 49:
return this.getType49Content(msg)
default:
- return msg.rawContent || null
+ return normalizeTextContent(msg.parsedContent || msg.rawContent) || null
}
}
diff --git a/electron/services/messagePushService.ts b/electron/services/messagePushService.ts
index cacdcf4..8a8c888 100644
--- a/electron/services/messagePushService.ts
+++ b/electron/services/messagePushService.ts
@@ -1325,13 +1325,19 @@ class MessagePushService {
}
private getMessageDisplayContent(message: Message): string | null {
+ const normalizeTextContent = (value: string | null | undefined): string | null => {
+ const text = String(value || '')
+ if (!text) return null
+ return text.replace(/^[\s]*([a-zA-Z0-9_@-]+):(?!\/\/)(?:\s*(?:\r?\n|
)\s*|\s*)/i, '').trim()
+ }
+
const cleanOfficialPrefix = (value: string | null): string | null => {
if (!value) return value
return value.replace(/^\s*\[视频号\]\s*/u, '').trim() || value
}
switch (Number(message.localType || 0)) {
case 1:
- return cleanOfficialPrefix(message.rawContent || null)
+ return cleanOfficialPrefix(normalizeTextContent(message.parsedContent || message.rawContent))
case 3:
return '[图片]'
case 34:
@@ -1347,7 +1353,7 @@ class MessagePushService {
case 49:
return cleanOfficialPrefix(message.linkTitle || message.fileName || '[消息]')
default:
- return cleanOfficialPrefix(message.parsedContent || message.rawContent || null)
+ return cleanOfficialPrefix(normalizeTextContent(message.parsedContent || message.rawContent) || null)
}
}