diff --git a/urbanLifelineWeb/packages/workcase_wechat/pages/chatRoom/chatRoom/chatRoom.scss b/urbanLifelineWeb/packages/workcase_wechat/pages/chatRoom/chatRoom/chatRoom.scss index 4883c35f..0d6a88d7 100644 --- a/urbanLifelineWeb/packages/workcase_wechat/pages/chatRoom/chatRoom/chatRoom.scss +++ b/urbanLifelineWeb/packages/workcase_wechat/pages/chatRoom/chatRoom/chatRoom.scss @@ -329,6 +329,7 @@ flex-direction: row; align-items: flex-start; gap: 16rpx; + width: 100%; } .other-row { @@ -363,12 +364,13 @@ .message-content { display: flex; flex-direction: column; - max-width: 480rpx; + max-width: 70%; + min-width: 0; // 允许flex子元素收缩 } // 会议卡片需要更宽的空间 .message-content.meeting-card-wrapper { - max-width: 600rpx; + max-width: 80%; } .self-row .message-content { @@ -382,11 +384,13 @@ } .bubble { - max-width: 480rpx; + max-width: 100%; padding: 18rpx 20rpx; border-radius: 18rpx; font-size: 28rpx; line-height: 1.6; + word-break: break-all; // 长单词/URL换行 + overflow-wrap: break-word; } .other-bubble { @@ -403,6 +407,15 @@ font-size: 28rpx; line-height: 1.6; white-space: pre-wrap; + word-break: break-all; + display: block; +} + +.message-rich-text { + font-size: 28rpx; + line-height: 1.6; + word-break: break-all; + overflow-wrap: break-word; } .message-time { diff --git a/urbanLifelineWeb/packages/workcase_wechat/pages/chatRoom/chatRoom/chatRoom.uvue b/urbanLifelineWeb/packages/workcase_wechat/pages/chatRoom/chatRoom/chatRoom.uvue index 2db2282f..6c163db5 100644 --- a/urbanLifelineWeb/packages/workcase_wechat/pages/chatRoom/chatRoom/chatRoom.uvue +++ b/urbanLifelineWeb/packages/workcase_wechat/pages/chatRoom/chatRoom/chatRoom.uvue @@ -470,10 +470,10 @@ function renderMarkdown(text: string): string { html = html.replace(/(?$1') // 处理行内代码(`语法) - html = html.replace(/`([^`]+)`/g, '$1') + html = html.replace(/`([^`]+)`/g, '$1') // 处理链接([text](url)语法) - html = html.replace(/\[([^\]]+)\]\(([^)]+)\)/g, '$1') + html = html.replace(/\[([^\]]+)\]\(([^)]+)\)/g, '$1') // 处理标题(# ## ###等) html = html.replace(/^### (.+)$/gm, '
$1
') @@ -486,7 +486,8 @@ function renderMarkdown(text: string): string { // 处理换行 html = html.replace(/\n/g, '
') - return html + // 包裹在带有换行样式的容器中 + return `
${html}
` } // 发送消息 diff --git a/urbanLifelineWeb/packages/workcase_wechat/pages/index/index.scss b/urbanLifelineWeb/packages/workcase_wechat/pages/index/index.scss index f80209b4..0cc4288c 100644 --- a/urbanLifelineWeb/packages/workcase_wechat/pages/index/index.scss +++ b/urbanLifelineWeb/packages/workcase_wechat/pages/index/index.scss @@ -337,6 +337,17 @@ word-wrap: break-word; } +// rich-text 组件样式(用于 Markdown 渲染) +.message-rich-text { + font-size: 14px; + line-height: 1.5; + word-wrap: break-word; + word-break: break-word; + overflow-wrap: break-word; + white-space: normal; + max-width: 100%; +} + .message-time { font-size: 11px; color: #999999; diff --git a/urbanLifelineWeb/packages/workcase_wechat/pages/index/index.uvue b/urbanLifelineWeb/packages/workcase_wechat/pages/index/index.uvue index 025371c5..6a90f8bf 100644 --- a/urbanLifelineWeb/packages/workcase_wechat/pages/index/index.uvue +++ b/urbanLifelineWeb/packages/workcase_wechat/pages/index/index.uvue @@ -599,7 +599,7 @@ await callAIChat(question) } - // Markdown渲染函数(返回富文本节点) + // Markdown渲染函数(返回富文本节点) function renderMarkdown(text : string) : string { if (!text) return '' @@ -609,30 +609,31 @@ .replace(//g, '>') - // 处理粗体(**语法) + // 处理粗体(**语法) html = html.replace(/\*\*([^\*]+)\*\*/g, '$1') - // 处理斜体(*语法,但要避免和粗体冲突) + // 处理斜体(*语法,但要避免和粗体冲突) html = html.replace(/(?$1') - // 处理行内代码(`语法) - html = html.replace(/`([^`]+)`/g, '$1') + // 处理行内代码(`语法) + html = html.replace(/`([^`]+)`/g, '$1') - // 处理链接([text](url)语法) - html = html.replace(/\[([^\]]+)\]\(([^)]+)\)/g, '$1') + // 处理链接([text](url)语法) + html = html.replace(/\[([^\]]+)\]\(([^)]+)\)/g, '$1') - // 处理标题(# ## ###等) - html = html.replace(/^### (.+)$/gm, '
$1
') - html = html.replace(/^## (.+)$/gm, '
$1
') - html = html.replace(/^# (.+)$/gm, '
$1
') + // 处理标题(# ## ###等) + html = html.replace(/^### (.+)$/gm, '
$1
') + html = html.replace(/^## (.+)$/gm, '
$1
') + html = html.replace(/^# (.+)$/gm, '
$1
') - // 处理无序列表(- 或 * 开头) - html = html.replace(/^[*-] (.+)$/gm, '
• $1
') + // 处理无序列表(- 或 * 开头) + html = html.replace(/^[*-] (.+)$/gm, '
• $1
') // 处理换行 html = html.replace(/\n/g, '
') - return html + // 包裹在一个具有换行样式的容器中 + return `
${html}
` } // 显示上传选项