chore(ai): 增加调试日志输出
This commit is contained in:
@@ -32,7 +32,15 @@ export default {
|
||||
*/
|
||||
async sendMessage(message, options = {}) {
|
||||
try {
|
||||
// 调试:打印关键状态
|
||||
console.log('[AI Service] sendMessage 开始执行');
|
||||
console.log('[AI Service] store.state.memberInfo:', store.state.memberInfo);
|
||||
console.log('[AI Service] store.state.uniacid:', store.state.uniacid);
|
||||
console.log('[AI Service] currentConversationId:', this.getConversationId());
|
||||
|
||||
const aiConfig = store.getters.globalAIKefuConfig;
|
||||
console.log('[AI Service] aiConfig:', aiConfig);
|
||||
|
||||
const params = {
|
||||
url: '/api/kefu/chat',
|
||||
data: {
|
||||
@@ -50,21 +58,30 @@ export default {
|
||||
}
|
||||
};
|
||||
|
||||
console.log('Sending blocking request to:', params.url);
|
||||
console.log('Request data:', params.data);
|
||||
console.log('[AI Service] 发送请求到:', params.url);
|
||||
console.log('[AI Service] 请求参数:', JSON.stringify(params.data, null, 2));
|
||||
|
||||
const response = await http.sendRequest({
|
||||
...params,
|
||||
async: false
|
||||
});
|
||||
|
||||
console.log('[AI Service] 收到响应:', response);
|
||||
|
||||
const result = this.handleResponse(response);
|
||||
if (result.conversationId) {
|
||||
this.setConversationId(result.conversationId);
|
||||
}
|
||||
return result;
|
||||
} catch (error) {
|
||||
console.error('Dify API请求失败:', error);
|
||||
console.error('[AI Service] Dify API请求失败,详细错误:', error);
|
||||
console.error('[AI Service] 错误堆栈:', error.stack);
|
||||
// 打印更多信息帮助调试
|
||||
console.error('[AI Service] store 状态:', {
|
||||
memberInfo: store.state.memberInfo,
|
||||
uniacid: store.state.uniacid,
|
||||
token: store.state.token
|
||||
});
|
||||
throw new Error('AI服务暂时不可用,请稍后重试');
|
||||
}
|
||||
},
|
||||
@@ -361,6 +378,7 @@ export default {
|
||||
async: false,
|
||||
data: {}
|
||||
});
|
||||
console.log('/api/kefu/health response', response);
|
||||
const available = [response?.data?.status, response?.data?.components?.ai_service_config?.status]
|
||||
.filter(item => item === 'healthy').length > 0;
|
||||
return {
|
||||
|
||||
@@ -1146,11 +1146,8 @@ async loadChatHistoryIfExist() {
|
||||
|
||||
// 格式化时间
|
||||
formatTime(timestamp) {
|
||||
console.log('【调试】formatTime 接收到的时间戳:', timestamp, typeof timestamp);
|
||||
|
||||
// 如果没有时间戳,就不显示时间
|
||||
if (!timestamp) {
|
||||
console.warn('【调试】没有时间戳');
|
||||
return '';
|
||||
}
|
||||
|
||||
@@ -1183,21 +1180,15 @@ async loadChatHistoryIfExist() {
|
||||
date = new Date(timeValue);
|
||||
}
|
||||
|
||||
console.log('【调试】最终 Date 对象:', date);
|
||||
console.log('【调试】本地时间:', date.toLocaleString());
|
||||
console.log('【调试】小时:', date.getHours());
|
||||
console.log('【调试】分钟:', date.getMinutes());
|
||||
|
||||
// 如果时间无效,就不显示时间
|
||||
if (isNaN(date.getTime())) {
|
||||
console.warn('【调试】时间无效:', timestamp);
|
||||
return '';
|
||||
}
|
||||
|
||||
const hours = date.getHours().toString().padStart(2, '0');
|
||||
const minutes = date.getMinutes().toString().padStart(2, '0');
|
||||
const result = hours + ':' + minutes;
|
||||
console.log('【调试】最终显示时间:', result);
|
||||
return result;
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user