This commit is contained in:
2025-07-25 16:18:33 +08:00
parent c09cbc3f01
commit a4c6140ed5
50 changed files with 2249 additions and 1599 deletions
+42 -15
View File
@@ -388,15 +388,12 @@
try {
emotionSummaryLoading.value = true
// 获取当前用户ID(这里需要根据实际的用户管理方式获取
const userId = chatStore.currentSession?.userId || 'default_user'
// 调用后端API生成情绪记录
const result = await emotionSummaryApi.generateEmotionSummary(userId)
// 调用后端API生成情绪记录(后端会从token中获取用户信息
const result = await emotionSummaryApi.generateEmotionSummary()
// 显示成功消息
const emotionRecord = result.emotionRecord
const summary = result.summary
// const emotionRecord = result.emotionRecord
// const summary = result.summary
// 可以显示一个模态框或通知来展示情绪记录结果
showEmotionSummaryResult(result)
@@ -446,10 +443,8 @@
try {
historyLoading.value = true
// 获取当前用户ID(这里需要根据实际的用户管理方式获取
const userId = chatStore.currentSession?.userId || 'default_user'
const pageData = await messageApi.getUserMessages(userId, page, historyPagination.value.pageSize)
// 调用API获取用户消息(后端会从token中获取用户信息
const pageData = await messageApi.getUserMessages(page, historyPagination.value.pageSize)
if (page === 1) {
historyMessages.value = pageData.records || []
@@ -482,9 +477,8 @@
try {
historyLoading.value = true
const userId = chatStore.currentSession?.userId || 'default_user'
const messages = await messageApi.searchUserMessages(userId, searchKeyword.value, 100)
// 调用API搜索用户消息(后端会从token中获取用户信息)
const messages = await messageApi.searchUserMessages(searchKeyword.value, 100)
historyMessages.value = messages || []
console.log('搜索历史记录成功:', historyMessages.value.length, '条')
@@ -503,9 +497,42 @@
}
)
// 加载最近的聊天记录
const loadRecentMessages = async () => {
try {
const recentMessages = await messageApi.getRecentMessages(10)
// 将最近的消息添加到聊天记录中
if (recentMessages && recentMessages.length > 0) {
// 转换为聊天消息格式
const chatMessages = recentMessages.map(msg => ({
id: msg.id,
content: msg.content,
sender: msg.sender === 'user' ? 'user' : 'ai',
timestamp: new Date(msg.createTime).getTime(),
type: 'text'
}))
// 按时间顺序排列(最新的在最后)
chatMessages.sort((a, b) => a.timestamp - b.timestamp)
// 添加到消息列表
messages.value.push(...chatMessages)
console.log('加载最近聊天记录成功:', chatMessages.length, '条')
}
} catch (error) {
console.error('加载最近聊天记录失败:', error)
}
}
// 组件挂载
onMounted(() => {
onMounted(async () => {
chatStore.initChat()
// 加载最近的聊天记录
await loadRecentMessages()
scrollToBottom()
})