mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-07-26 17:13:54 +08:00
update: mobile 聊天记录获取最新数据
This commit is contained in:
@@ -283,7 +283,6 @@ function updateDisplayNames() {
|
||||
|
||||
// 角色音色特殊处理
|
||||
displayNames.value.report = reportOptions.find(item => item.value === formData.value.chatHistoryConf)?.name
|
||||
displayNames.value.language = formData.value.ttsLanguage
|
||||
|
||||
isVisibleReport.value = formData.value.memModelId !== 'Memory_nomem'
|
||||
|
||||
|
||||
@@ -285,7 +285,6 @@ onLoad((options) => {
|
||||
if (options?.sessionId && options?.agentId) {
|
||||
sessionId.value = options.sessionId
|
||||
agentId.value = options.agentId
|
||||
loadChatHistory()
|
||||
}
|
||||
else {
|
||||
console.error('缺少必要参数')
|
||||
@@ -293,6 +292,10 @@ onLoad((options) => {
|
||||
}
|
||||
})
|
||||
|
||||
onShow(() => {
|
||||
loadChatHistory()
|
||||
})
|
||||
|
||||
// 页面销毁时清理音频资源
|
||||
onUnload(() => {
|
||||
if (audioContext.value) {
|
||||
|
||||
@@ -3,6 +3,7 @@ import type { ChatSession } from '@/api/chat-history/types'
|
||||
import { computed, onMounted, ref } from 'vue'
|
||||
import { getChatSessions } from '@/api/chat-history/chat-history'
|
||||
import { t } from '@/i18n'
|
||||
import { deepClone } from '@/utils'
|
||||
|
||||
defineOptions({
|
||||
name: 'ChatHistory',
|
||||
@@ -43,7 +44,7 @@ const sessionList = ref<ChatSession[]>([])
|
||||
const loading = ref(false)
|
||||
const loadingMore = ref(false)
|
||||
const hasMore = ref(true)
|
||||
const currentPage = ref(1)
|
||||
const currentPage = ref(0)
|
||||
const pageSize = 10
|
||||
|
||||
// 使用传入的智能体ID
|
||||
@@ -52,10 +53,8 @@ const currentAgentId = computed(() => {
|
||||
})
|
||||
|
||||
// 加载聊天会话列表
|
||||
async function loadChatSessions(page = 1, isRefresh = false) {
|
||||
async function loadChatSessions(page = 1, isUpdate = false) {
|
||||
try {
|
||||
console.log(t('chatHistory.getChatSessions'), { page, isRefresh })
|
||||
|
||||
// 检查是否有当前选中的智能体
|
||||
if (!currentAgentId.value) {
|
||||
console.warn(t('chatHistory.noSelectedAgent'))
|
||||
@@ -76,7 +75,10 @@ async function loadChatSessions(page = 1, isRefresh = false) {
|
||||
})
|
||||
|
||||
if (page === 1) {
|
||||
sessionList.value = response.list || []
|
||||
const oldSessionList = deepClone(sessionList.value)
|
||||
oldSessionList.splice(0, 10)
|
||||
oldSessionList.unshift(...(response.list || []))
|
||||
sessionList.value = isUpdate ? oldSessionList : response.list || []
|
||||
}
|
||||
else {
|
||||
sessionList.value.push(...(response.list || []))
|
||||
@@ -170,10 +172,15 @@ function goToChatDetail(session: ChatSession) {
|
||||
|
||||
onMounted(async () => {
|
||||
// 智能体已简化为默认
|
||||
|
||||
loadChatSessions(1)
|
||||
})
|
||||
|
||||
onShow(() => {
|
||||
if (currentPage.value !== 0) {
|
||||
loadChatSessions(1, true)
|
||||
}
|
||||
})
|
||||
|
||||
// 暴露方法给父组件
|
||||
defineExpose({
|
||||
refresh,
|
||||
|
||||
Reference in New Issue
Block a user