fix: improve chat detail page navigation

This commit is contained in:
2026-07-30 15:32:56 +08:00
parent 918ef5fa79
commit 1f82b89295
2 changed files with 24 additions and 2 deletions

View File

@@ -1,6 +1,6 @@
<script setup lang="ts">
import { ElMessage, ElMessageBox } from "element-plus";
import { computed, onMounted, reactive, ref, watch } from "vue";
import { computed, nextTick, onMounted, reactive, ref, watch } from "vue";
import AdminLoginView from "./components/AdminLoginView.vue";
import AdminPagination from "./components/AdminPagination.vue";
@@ -55,6 +55,7 @@ const chatDetailOpen = ref(false);
const chatDetailLoading = ref(false);
const chatMessagesLoading = ref(false);
const chatDetailSessionId = ref<number | null>(null);
const chatDetailBodyRef = ref<HTMLElement | null>(null);
const selectedAiLog = ref<AiLogRecord | null>(null);
const aiLogDetailOpen = ref(false);
const recordTab = ref("chats");
@@ -784,6 +785,8 @@ async function changeChatDetailMessagePage(page: number, pageSize: number) {
messagesPage: result,
};
Object.assign(chatDetailMessagePager, { page: result.page, pageSize: result.pageSize, total: result.total });
await nextTick();
chatDetailBodyRef.value?.scrollTo({ top: 0, behavior: "smooth" });
} catch (error) {
ElMessage.error(error instanceof Error ? error.message : "聊天消息加载失败");
} finally {
@@ -1249,7 +1252,7 @@ function formatRecordDateTime(value: string, boundary: "start" | "end") {
</el-drawer>
<el-drawer v-model="chatDetailOpen" size="760px" title="聊天详情">
<div v-loading="chatDetailLoading" class="chat-detail-body">
<div ref="chatDetailBodyRef" v-loading="chatDetailLoading" class="chat-detail-body">
<template v-if="chatDetail">
<section class="chat-summary">
<div><span>会话ID</span><strong>{{ chatDetail.session.id }}</strong></div>
@@ -1259,6 +1262,13 @@ function formatRecordDateTime(value: string, boundary: "start" | "end") {
</section>
<h3 class="detail-title">完整对话</h3>
<AdminPagination
class="chat-detail-pagination top"
:page="chatDetailMessagePager.page"
:page-size="chatDetailMessagePager.pageSize"
:total="chatDetailMessagePager.total"
@change="changeChatDetailMessagePage"
/>
<section v-loading="chatMessagesLoading" class="conversation-list">
<article
v-for="message in chatDetail.messages"
@@ -1280,6 +1290,7 @@ function formatRecordDateTime(value: string, boundary: "start" | "end") {
</article>
</section>
<AdminPagination
class="chat-detail-pagination"
:page="chatDetailMessagePager.page"
:page-size="chatDetailMessagePager.pageSize"
:total="chatDetailMessagePager.total"