mirror of
https://github.com/hicccc77/WeFlow.git
synced 2026-03-25 07:16:51 +00:00
fix(ChatService, VideoService): 优化系统消息清理逻辑并移除冗余日志
- 改进 cleanSystemMessage 方法,增强 XML 声明移除和尾部时间戳清理 - 优化正则表达式以更准确地处理 XML/HTML 标签 - 从 VideoService 中移除大量冗余的 console.log 调试日志 - 简化错误处理,使用注释替代冗余日志输出 - 提升代码可读性和性能,减少不必要的日志输出开销
This commit is contained in:
@@ -1480,11 +1480,15 @@ class ChatService {
|
||||
}
|
||||
|
||||
private cleanSystemMessage(content: string): string {
|
||||
return content
|
||||
.replace(/<img[^>]*>/gi, '')
|
||||
.replace(/<\/?[a-zA-Z0-9_]+[^>]*>/g, '')
|
||||
.replace(/\s+/g, ' ')
|
||||
.trim() || '[系统消息]'
|
||||
// 移除 XML 声明
|
||||
let cleaned = content.replace(/<\?xml[^?]*\?>/gi, '')
|
||||
// 移除所有 XML/HTML 标签
|
||||
cleaned = cleaned.replace(/<[^>]+>/g, '')
|
||||
// 移除尾部的数字(如撤回消息后的时间戳)
|
||||
cleaned = cleaned.replace(/\d+\s*$/, '')
|
||||
// 清理多余空白
|
||||
cleaned = cleaned.replace(/\s+/g, ' ').trim()
|
||||
return cleaned || '[系统消息]'
|
||||
}
|
||||
|
||||
private stripSenderPrefix(content: string): string {
|
||||
|
||||
Reference in New Issue
Block a user