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): 渲染文本提取