add ai chat entry

This commit is contained in:
Timi
2026-11-04 14:17:32 +08:00
parent aa1edd4056
commit 7067c63d46
4 changed files with 105 additions and 9 deletions
+17 -7
View File
@@ -1,15 +1,17 @@
<template>
<t-popup
<component
:is="props.inline ? 'div' : TPopup"
v-model="popupVisible"
placement="right"
destroy-on-close
:z-index="popupZIndex"
:overlay-props="{ zIndex: popupZIndex - 1 }"
>
<section class="ai-conversation-list" @scroll="handleScroll">
<section class="ai-conversation-list" :class="{ inline: props.inline }" @scroll="handleScroll">
<header class="header glass-header">
<h3>历史会话</h3>
<t-button
v-if="!props.inline"
theme="danger"
shape="circle"
variant="text"
@@ -77,11 +79,11 @@
/>
</div>
</section>
</t-popup>
</component>
</template>
<script setup lang="ts">
import { DialogPlugin } from "tdesign-mobile-vue";
import { DialogPlugin, Popup as TPopup } from "tdesign-mobile-vue";
import { deleteConversation as removeConversation, type GaoAiConversation, listConversations } from "@/api/GaoAiAPI";
import { getErrorMessage } from "@/utils/error";
import { Message } from "@/utils/message";
@@ -93,6 +95,7 @@ defineOptions({
interface Props {
visible: boolean;
inline?: boolean;
activeConversationId: string;
disabled: boolean;
sessionKey: string;
@@ -251,18 +254,18 @@ function formatConversationTime(conversation: GaoAiConversation): number {
return timestamp < 100000000000 ? timestamp * 1000 : timestamp;
}
watch(() => props.visible, async visible => {
watch(() => props.inline || props.visible, async visible => {
if (visible) {
await reloadList();
}
});
}, { immediate: true });
watch(() => props.sessionKey, async () => {
requestToken += 1;
conversationList.value = [];
lastId.value = "";
isNoMore.value = false;
if (props.visible) {
if (props.inline || props.visible) {
await reloadList();
}
});
@@ -278,6 +281,13 @@ watch(() => props.sessionKey, async () => {
position: relative;
flex-direction: column;
&.inline {
width: 18rem;
height: 100%;
padding: calc(var(--tui-nav-height) + .5rem) 0 0 0;
border-right: 1px solid var(--td-component-border);
}
.header {
top: 0;
z-index: 1;