From 235adb5ebd673c3dbb72bfab57269a6c1977e910 Mon Sep 17 00:00:00 2001 From: ZF sun <34314687@qq.com> Date: Sun, 20 Sep 2026 18:25:59 +0800 Subject: [PATCH] =?UTF-8?q?chore=EF=BC=9A=E4=BC=98=E5=8C=96=E5=B7=A5?= =?UTF-8?q?=E5=85=B7=E8=B0=83=E7=94=A8=E7=9A=84=E5=8F=AF=E8=A7=81=E6=80=A7?= =?UTF-8?q?=E6=8E=A7=E5=88=B6=EF=BC=8C=E7=A1=AE=E4=BF=9D=E4=B8=8E=E6=80=9D?= =?UTF-8?q?=E8=80=83=E8=BF=87=E7=A8=8B=E5=BC=80=E5=85=B3=E4=B8=80=E8=87=B4?= =?UTF-8?q?=EF=BC=9B=E7=BB=9F=E4=B8=80=E6=AC=A2=E8=BF=8E=E8=AF=AD=E5=AD=97?= =?UTF-8?q?=E6=AE=B5=E5=90=8D=EF=BC=8C=E7=A7=BB=E9=99=A4=E5=86=97=E4=BD=99?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=EF=BC=9B=E5=85=BC=E5=AE=B9=E6=97=A7=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E6=A0=BC=E5=BC=8F=EF=BC=8C=E6=8F=90=E5=8D=87=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E5=A4=84=E7=90=86=E7=9A=84=E5=81=A5=E5=A3=AE=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages_tool/ai-chat/ai-chat-message.vue | 36 +++++++++++++++++++------- 1 file changed, 27 insertions(+), 9 deletions(-) diff --git a/pages_tool/ai-chat/ai-chat-message.vue b/pages_tool/ai-chat/ai-chat-message.vue index 04eb151..61a5a30 100644 --- a/pages_tool/ai-chat/ai-chat-message.vue +++ b/pages_tool/ai-chat/ai-chat-message.vue @@ -319,7 +319,11 @@ - + + 🔧 {{ tc.tool_name }}: {{ tc.status }}{{ tc.duration_ms ? (' (' + tc.duration_ms + 'ms)') : '' }} @@ -1084,6 +1088,8 @@ export default { let welcomeLoaded = false // PR-FIX (2026-09-20): welcomeInfo 原为 if 块内 const,第 3 步拼 quickQuestions // 时在块外引用 → ReferenceError, 提升到函数作用域 + // PR-WELCOME-INFO-CONSOLIDATE (2026-09-20): 字段名统一为 welcome, 移除 welcome_info + // 后端 KefuGetInfo 只下发 welcome 一个字段 (结构不变) let welcomeInfo = null // 1. 尝试从 API 获取远程欢迎语 @@ -1091,7 +1097,7 @@ export default { const config = await aiService.getServiceConfig() console.log('[AI Chat] API getServiceConfig 返回:', JSON.stringify(config)) if (config) { - welcomeInfo = config.welcome_info + welcomeInfo = config.welcome console.log('[AI Chat] welcomeInfo:', JSON.stringify(welcomeInfo)) const remoteText = welcomeInfo?.welcome || '' const isEnabled = welcomeInfo?.is_enabled @@ -1144,15 +1150,27 @@ export default { // PR-WELCOME-QUICK-CHIPS (2026-09-19): 归一化 quick_questions 数据格式 // 后端可能存 string[] ("如何下单?" / "退换货流程") // 也可能存 {id, text}[] ({id:'q1',text:'如何下单?'}) + // PR-WELCOME-QUICK-NORMALIZE (2026-09-20): 兼容 textarea 时代的 string 格式 + // 老数据 PR-WELCOME-SAVE-SANITIZE 上线前存的是 newline-separated string + // 例如 "如何下单?\n退换货流程\n价格说明",前端按 \n 切分兼容 + // 后端 KefuGetInfo 已做归一化 (2026-09-20),前端是双保险 // 前端统一抽出 text,空值过滤 normalizeQuickQuestions(raw) { - if (!Array.isArray(raw)) return [] - return raw - .map(function (q) { - if (q && typeof q === 'object') return q.text || q.label || '' - return String(q || '') - }) - .filter(function (s) { return s && s.trim() !== '' }) + if (Array.isArray(raw)) { + return raw + .map(function (q) { + if (q && typeof q === 'object') return q.text || q.label || '' + return String(q || '') + }) + .filter(function (s) { return s && s.trim() !== '' }) + } + // 兼容老数据 string 格式 (PR-WELCOME-SAVE-SANITIZE 上线前) + if (typeof raw === 'string' && raw !== '') { + return raw.split(/\r\n|\r|\n/) + .map(function (s) { return s.trim() }) + .filter(function (s) { return s !== '' }) + } + return [] }, // PR-WELCOME-QUICK-CHIPS (2026-09-19): 渲染文本提取