From 3c88e179866d13e2346f8b8e006dd086016d717c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=B9=8F=E5=AE=87?= Date: Fri, 12 Jun 2026 16:51:35 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9B=BE=E7=89=87=E8=AF=86=E5=88=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- yuthon_ai_agent/static/src/css/ai_chat.css | 7 ------ .../static/src/css/ai_floating.css | 7 ------ .../static/src/js/ai_chat_action.js | 19 ++++++++++++++- yuthon_ai_agent/static/src/js/ai_floating.js | 23 ++++++++++++++++++- 4 files changed, 40 insertions(+), 16 deletions(-) diff --git a/yuthon_ai_agent/static/src/css/ai_chat.css b/yuthon_ai_agent/static/src/css/ai_chat.css index 6ef96cd39..52aecc9a7 100644 --- a/yuthon_ai_agent/static/src/css/ai_chat.css +++ b/yuthon_ai_agent/static/src/css/ai_chat.css @@ -157,13 +157,6 @@ font-size: 12px; white-space: nowrap; } -.o_ai_link_url { - font-size: 11px; - opacity: 0.7; - overflow: hidden; - text-overflow: ellipsis; - white-space: nowrap; -} /* === 消息中附件缩略图 === */ .ai-chat-msg-attachments { diff --git a/yuthon_ai_agent/static/src/css/ai_floating.css b/yuthon_ai_agent/static/src/css/ai_floating.css index 218b97fdc..85bc69b4e 100644 --- a/yuthon_ai_agent/static/src/css/ai_floating.css +++ b/yuthon_ai_agent/static/src/css/ai_floating.css @@ -366,13 +366,6 @@ font-size: 12px; white-space: nowrap; } -.o_ai_link_url { - font-size: 11px; - opacity: 0.7; - overflow: hidden; - text-overflow: ellipsis; - white-space: nowrap; -} /* === 消息中的附件缩略图 === */ .o_ai_msg_attachments { diff --git a/yuthon_ai_agent/static/src/js/ai_chat_action.js b/yuthon_ai_agent/static/src/js/ai_chat_action.js index c0f784c49..673d1daf1 100644 --- a/yuthon_ai_agent/static/src/js/ai_chat_action.js +++ b/yuthon_ai_agent/static/src/js/ai_chat_action.js @@ -35,7 +35,24 @@ export class AiChatAction extends Component { .replace(/【附件:[^】]+】[\s\S]*?--- 附件内容结束 ---/g, '') .replace(/\[附件[::]\s*[^\]]+\]\n?/g, '') .trim() || safe; - // 不做额外处理,URL 保持纯文本显示 + // 1) 先处理 Markdown 风格链接 [显示名](url) → 卡片使用自定义名称 + display = display.replace( + /\[([^\]]+)\]\((https?:\/\/[^\s<>"')\u4e00-\u9fff\u3000-\u303f\uff00-\uffef]+)\)/g, + (_, label, url) => { + const rawUrl = url.replace(/&/g, '&'); + return `${this._escapeHtml(label)}`; + } + ); + // 2) 再处理裸 URL → 域名作为卡片名称 + display = display.replace( + /(https?:\/\/[^\s<>"'\u4e00-\u9fff\u3000-\u303f\uff00-\uffef]+)/g, + (url) => { + const rawUrl = url.replace(/&/g, '&'); + let domain = ''; + try { domain = new URL(rawUrl).hostname; } catch (_) { domain = rawUrl; } + return `${this._escapeHtml(domain)}`; + } + ); return display.replace(/\n/g, '
'); } diff --git a/yuthon_ai_agent/static/src/js/ai_floating.js b/yuthon_ai_agent/static/src/js/ai_floating.js index e0f36358b..3d21abca8 100644 --- a/yuthon_ai_agent/static/src/js/ai_floating.js +++ b/yuthon_ai_agent/static/src/js/ai_floating.js @@ -235,7 +235,28 @@ function renderContent(text) { .replace(/【附件:[^】]+】[\s\S]*?--- 附件内容结束 ---/g, '') .replace(/\[附件[::]\s*[^\]]+\]\n?/g, '') .trim() || safe; // 若 strip 后为空,回退到 safe 继续处理 URL - // 不做额外处理,URL 保持纯文本显示 + // 1) 先处理 Markdown 风格链接 [显示名](url) → 卡片使用自定义名称 + display = display.replace( + /\[([^\]]+)\]\((https?:\/\/[^\s<>"')\u4e00-\u9fff\u3000-\u303f\uff00-\uffef]+)\)/g, + (_, label, url) => { + const rawUrl = url.replace(/&/g, '&'); + return `${escapeHtml(label)}`; + } + ); + // 2) 再处理裸 URL → 域名作为卡片名称 + display = display.replace( + /(https?:\/\/[^\s<>"'\u4e00-\u9fff\u3000-\u303f\uff00-\uffef]+)/g, + (url) => { + const rawUrl = url.replace(/&/g, '&'); + let domain = ''; + try { + domain = new URL(rawUrl).hostname; + } catch (_) { + domain = rawUrl; + } + return `${escapeHtml(domain)}`; + } + ); // 换行转
display = display.replace(/\n/g, '
'); return display;