chore:优化工具调用的可见性控制,确保与思考过程开关一致;统一欢迎语字段名,移除冗余信息;兼容旧数据格式,提升数据处理的健壮性
This commit is contained in:
@@ -319,7 +319,11 @@
|
|||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 工具调用 (调试可见性) -->
|
<!-- 工具调用 (调试可见性) -->
|
||||||
<view v-if="message.toolCalls && message.toolCalls.length" class="tool-calls">
|
<!-- PR-CHAT-UI-CONFIG-TOOL-CALLS (2026-09-20): 受 ui_show_thinking_process 控制
|
||||||
|
修复前: v-if 只判断数据存在, 关掉"显示 AI 思考过程"后 tool-calls 仍显示
|
||||||
|
修复后: 与 thought-panel 共用同一开关, "思考过程可见性"统一管理
|
||||||
|
后端不动, 仅前端加条件渲染 -->
|
||||||
|
<view v-if="message.toolCalls && message.toolCalls.length && chatUiConfig.ui_show_thinking_process" class="tool-calls">
|
||||||
<view v-for="tc in message.toolCalls" :key="tc.tool_call_id || tc.id" class="tool-call-item" :class="['status-' + (tc.status || 'pending')]">
|
<view v-for="tc in message.toolCalls" :key="tc.tool_call_id || tc.id" class="tool-call-item" :class="['status-' + (tc.status || 'pending')]">
|
||||||
<text>🔧 {{ tc.tool_name }}: {{ tc.status }}{{ tc.duration_ms ? (' (' + tc.duration_ms + 'ms)') : '' }}</text>
|
<text>🔧 {{ tc.tool_name }}: {{ tc.status }}{{ tc.duration_ms ? (' (' + tc.duration_ms + 'ms)') : '' }}</text>
|
||||||
</view>
|
</view>
|
||||||
@@ -1084,6 +1088,8 @@ export default {
|
|||||||
let welcomeLoaded = false
|
let welcomeLoaded = false
|
||||||
// PR-FIX (2026-09-20): welcomeInfo 原为 if 块内 const,第 3 步拼 quickQuestions
|
// PR-FIX (2026-09-20): welcomeInfo 原为 if 块内 const,第 3 步拼 quickQuestions
|
||||||
// 时在块外引用 → ReferenceError, 提升到函数作用域
|
// 时在块外引用 → ReferenceError, 提升到函数作用域
|
||||||
|
// PR-WELCOME-INFO-CONSOLIDATE (2026-09-20): 字段名统一为 welcome, 移除 welcome_info
|
||||||
|
// 后端 KefuGetInfo 只下发 welcome 一个字段 (结构不变)
|
||||||
let welcomeInfo = null
|
let welcomeInfo = null
|
||||||
|
|
||||||
// 1. 尝试从 API 获取远程欢迎语
|
// 1. 尝试从 API 获取远程欢迎语
|
||||||
@@ -1091,7 +1097,7 @@ export default {
|
|||||||
const config = await aiService.getServiceConfig()
|
const config = await aiService.getServiceConfig()
|
||||||
console.log('[AI Chat] API getServiceConfig 返回:', JSON.stringify(config))
|
console.log('[AI Chat] API getServiceConfig 返回:', JSON.stringify(config))
|
||||||
if (config) {
|
if (config) {
|
||||||
welcomeInfo = config.welcome_info
|
welcomeInfo = config.welcome
|
||||||
console.log('[AI Chat] welcomeInfo:', JSON.stringify(welcomeInfo))
|
console.log('[AI Chat] welcomeInfo:', JSON.stringify(welcomeInfo))
|
||||||
const remoteText = welcomeInfo?.welcome || ''
|
const remoteText = welcomeInfo?.welcome || ''
|
||||||
const isEnabled = welcomeInfo?.is_enabled
|
const isEnabled = welcomeInfo?.is_enabled
|
||||||
@@ -1144,15 +1150,27 @@ export default {
|
|||||||
// PR-WELCOME-QUICK-CHIPS (2026-09-19): 归一化 quick_questions 数据格式
|
// PR-WELCOME-QUICK-CHIPS (2026-09-19): 归一化 quick_questions 数据格式
|
||||||
// 后端可能存 string[] ("如何下单?" / "退换货流程")
|
// 后端可能存 string[] ("如何下单?" / "退换货流程")
|
||||||
// 也可能存 {id, text}[] ({id:'q1',text:'如何下单?'})
|
// 也可能存 {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,空值过滤
|
// 前端统一抽出 text,空值过滤
|
||||||
normalizeQuickQuestions(raw) {
|
normalizeQuickQuestions(raw) {
|
||||||
if (!Array.isArray(raw)) return []
|
if (Array.isArray(raw)) {
|
||||||
return raw
|
return raw
|
||||||
.map(function (q) {
|
.map(function (q) {
|
||||||
if (q && typeof q === 'object') return q.text || q.label || ''
|
if (q && typeof q === 'object') return q.text || q.label || ''
|
||||||
return String(q || '')
|
return String(q || '')
|
||||||
})
|
})
|
||||||
.filter(function (s) { return s && s.trim() !== '' })
|
.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): 渲染文本提取
|
// PR-WELCOME-QUICK-CHIPS (2026-09-19): 渲染文本提取
|
||||||
|
|||||||
Reference in New Issue
Block a user