|
|
@ -81,9 +81,9 @@ var ChatbotSDK = (function () { |
|
|
this.timeEnd(`send_${integrateId}`); |
|
|
this.timeEnd(`send_${integrateId}`); |
|
|
this.error(`请求失败 integrateId=${integrateId} status=${status} message=${message}`); |
|
|
this.error(`请求失败 integrateId=${integrateId} status=${status} message=${message}`); |
|
|
}, |
|
|
}, |
|
|
/** 生命周期日志:清空会话 */ |
|
|
|
|
|
|
|
|
/** 生命周期日志:新对话 */ |
|
|
lifecycleClear(integrateId) { |
|
|
lifecycleClear(integrateId) { |
|
|
this.info(`清空会话 integrateId=${integrateId}`); |
|
|
|
|
|
|
|
|
this.info(`新对话 integrateId=${integrateId}`); |
|
|
}, |
|
|
}, |
|
|
/** 生命周期日志:流式回复完成 */ |
|
|
/** 生命周期日志:流式回复完成 */ |
|
|
lifecycleStreamDone(integrateId, length) { |
|
|
lifecycleStreamDone(integrateId, length) { |
|
|
@ -206,9 +206,8 @@ var ChatbotSDK = (function () { |
|
|
source_title: '参考来源', |
|
|
source_title: '参考来源', |
|
|
source_count: '{n} 条参考来源', |
|
|
source_count: '{n} 条参考来源', |
|
|
source_loading: '加载来源中...', |
|
|
source_loading: '加载来源中...', |
|
|
// 清空/管理
|
|
|
|
|
|
clear: '清空对话', |
|
|
|
|
|
clear_confirm: '确定清空所有对话记录?', |
|
|
|
|
|
|
|
|
// 新对话
|
|
|
|
|
|
clear: '新对话', |
|
|
// 历史会话
|
|
|
// 历史会话
|
|
|
history_title: '历史会话', |
|
|
history_title: '历史会话', |
|
|
history_empty: '暂无历史会话', |
|
|
history_empty: '暂无历史会话', |
|
|
@ -274,9 +273,8 @@ var ChatbotSDK = (function () { |
|
|
source_title: 'Sources', |
|
|
source_title: 'Sources', |
|
|
source_count: '{n} source(s)', |
|
|
source_count: '{n} source(s)', |
|
|
source_loading: 'Loading sources...', |
|
|
source_loading: 'Loading sources...', |
|
|
// Clear/Management
|
|
|
|
|
|
clear: 'Clear chat', |
|
|
|
|
|
clear_confirm: 'Clear all conversation history?', |
|
|
|
|
|
|
|
|
// Clear/New chat
|
|
|
|
|
|
clear: 'New chat', |
|
|
// History
|
|
|
// History
|
|
|
history_title: 'History', |
|
|
history_title: 'History', |
|
|
history_empty: 'No conversations yet', |
|
|
history_empty: 'No conversations yet', |
|
|
@ -1544,7 +1542,7 @@ var ChatbotSDK = (function () { |
|
|
.csk-dark .csk-disclaimer { color: #6B7280; } |
|
|
.csk-dark .csk-disclaimer { color: #6B7280; } |
|
|
.csk-dark .csk-disclaimer__title { color: #6B7280; } |
|
|
.csk-dark .csk-disclaimer__title { color: #6B7280; } |
|
|
|
|
|
|
|
|
/* ========== 清空按钮 ========== */ |
|
|
|
|
|
|
|
|
/* ========== 新对话按钮 ========== */ |
|
|
.csk-clear-btn { |
|
|
.csk-clear-btn { |
|
|
display: inline-flex; |
|
|
display: inline-flex; |
|
|
align-items: center; |
|
|
align-items: center; |
|
|
@ -2751,7 +2749,7 @@ var ChatbotSDK = (function () { |
|
|
} |
|
|
} |
|
|
inputArea.appendChild(disclaimer); |
|
|
inputArea.appendChild(disclaimer); |
|
|
windowEl.appendChild(inputArea); |
|
|
windowEl.appendChild(inputArea); |
|
|
// 清空按钮(可选)
|
|
|
|
|
|
|
|
|
// 新对话按钮(可选)
|
|
|
let clearBtn = null; |
|
|
let clearBtn = null; |
|
|
if (config.showClear) { |
|
|
if (config.showClear) { |
|
|
clearBtn = document.createElement('button'); |
|
|
clearBtn = document.createElement('button'); |
|
|
@ -4530,12 +4528,10 @@ var ChatbotSDK = (function () { |
|
|
messagesContainer$1.appendChild(historyPanelEl); |
|
|
messagesContainer$1.appendChild(historyPanelEl); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
/** 清空对话历史(生成新 chatId) */ |
|
|
|
|
|
|
|
|
/** 开启新对话(生成新 chatId) */ |
|
|
function handleClear() { |
|
|
function handleClear() { |
|
|
if (!config$1) |
|
|
if (!config$1) |
|
|
return; |
|
|
return; |
|
|
if (!confirm(t('clear_confirm'))) |
|
|
|
|
|
return; |
|
|
|
|
|
messages = []; |
|
|
messages = []; |
|
|
if (messagesContainer$1) { |
|
|
if (messagesContainer$1) { |
|
|
const msgs = messagesContainer$1.querySelectorAll('.csk-msg, .csk-loading'); |
|
|
const msgs = messagesContainer$1.querySelectorAll('.csk-msg, .csk-loading'); |
|
|
@ -4618,7 +4614,7 @@ var ChatbotSDK = (function () { |
|
|
logger.warn(`切换角色后加载后端历史失败 roleId=${newRoleId}`, err); |
|
|
logger.warn(`切换角色后加载后端历史失败 roleId=${newRoleId}`, err); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
// 10. 隐藏清空按钮 + 更新欢迎态
|
|
|
|
|
|
|
|
|
// 10. 隐藏新对话按钮 + 更新欢迎态
|
|
|
if (clearBtn$1 && messages.length === 0) |
|
|
if (clearBtn$1 && messages.length === 0) |
|
|
clearBtn$1.style.display = 'none'; |
|
|
clearBtn$1.style.display = 'none'; |
|
|
updateEmptyState(); |
|
|
updateEmptyState(); |
|
|
@ -4732,7 +4728,7 @@ var ChatbotSDK = (function () { |
|
|
catch (err) { |
|
|
catch (err) { |
|
|
logger.warn(`加载会话消息失败 conversationId=${conversationId}`, err); |
|
|
logger.warn(`加载会话消息失败 conversationId=${conversationId}`, err); |
|
|
} |
|
|
} |
|
|
// 5. 显示清空按钮
|
|
|
|
|
|
|
|
|
// 5. 显示新对话按钮
|
|
|
if (clearBtn$1 && messages.length > 0) { |
|
|
if (clearBtn$1 && messages.length > 0) { |
|
|
clearBtn$1.style.display = 'inline-flex'; |
|
|
clearBtn$1.style.display = 'inline-flex'; |
|
|
} |
|
|
} |
|
|
@ -5141,7 +5137,7 @@ var ChatbotSDK = (function () { |
|
|
if (clearBtn) { |
|
|
if (clearBtn) { |
|
|
clearBtn.click(); |
|
|
clearBtn.click(); |
|
|
} |
|
|
} |
|
|
else if (confirm('确定清空所有对话记录?')) { |
|
|
|
|
|
|
|
|
else { |
|
|
clearMessages(config.integrateId); |
|
|
clearMessages(config.integrateId); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|