From d6bef043570541b065c0c39aaf34d9b7979de769 Mon Sep 17 00:00:00 2001 From: SeasonsChange <1204992313@qq.com> Date: Fri, 22 Aug 2025 22:30:26 +0800 Subject: [PATCH] =?UTF-8?q?fix(MindMapTree):=20=E8=B0=83=E6=95=B4=E8=8A=82?= =?UTF-8?q?=E7=82=B9=E5=9B=BE=E6=A0=87=E5=92=8C=E6=96=87=E6=9C=AC=E4=BD=8D?= =?UTF-8?q?=E7=BD=AE=E5=B9=B6=E4=BC=98=E5=8C=96=E6=96=87=E6=9C=AC=E6=88=AA?= =?UTF-8?q?=E6=96=AD=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/components/Chat/MindMapTree.vue | 28 ++++--------------- 1 file changed, 6 insertions(+), 22 deletions(-) diff --git a/prompto-lab-ui/src/components/Chat/MindMapTree.vue b/prompto-lab-ui/src/components/Chat/MindMapTree.vue index 2f94b74..164b758 100644 --- a/prompto-lab-ui/src/components/Chat/MindMapTree.vue +++ b/prompto-lab-ui/src/components/Chat/MindMapTree.vue @@ -55,8 +55,8 @@ {{ node.type === 'user' ? '👤' : '🤖' }} @@ -64,8 +64,8 @@ {{ node.truncatedText }} @@ -184,32 +184,16 @@ const layoutNodes = computed(() => { // 基于节点宽度和字体大小计算最大字符数 // 节点宽度200px,减去图标35px和右侧边距20px,可用宽度约145px // 字体大小13px,平均字符宽度约8px(中文)或6px(英文) - const availableWidth = maxWidth - 55 // 减去图标和边距 - const avgCharWidth = /[\u4e00-\u9fa5]/.test(text) ? 8 : 6 // 中文字符更宽 + const availableWidth = maxWidth - 75 // 减去图标和边距 + const avgCharWidth = /[\u4e00-\u9fa5]/.test(text) ? 10 : 8 // 中文字符更宽 const maxChars = Math.floor(availableWidth / avgCharWidth) if (text.length <= maxChars) { return text } - // 优先在标点符号处截断 - const punctuation = /[。!?;,、]/ let truncateIndex = maxChars - 4 // 为省略号留空间 - // 向前查找最近的标点符号 - for (let i = truncateIndex; i >= Math.max(0, truncateIndex - 10); i--) { - if (punctuation.test(text[i])) { - truncateIndex = i + 1 - break - } - } - - // 避免在单词中间截断(英文) - if (!/[\u4e00-\u9fa5]/.test(text)) { - while (truncateIndex > 0 && text[truncateIndex] !== ' ' && text[truncateIndex - 1] !== ' ') { - truncateIndex-- - } - } return text.substring(0, truncateIndex).trim() + '...' }