add ai chat entry
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
>
|
||||
<template #right>
|
||||
<t-button
|
||||
v-if="canUseAi"
|
||||
v-if="canUseAi && !railVisible"
|
||||
:disabled="aiChatPanelRef?.isBusy"
|
||||
@click="aiChatPanelRef?.openConversationList()"
|
||||
theme="primary"
|
||||
@@ -21,6 +21,7 @@
|
||||
<div v-if="canUseAi" class="ai-chat-page">
|
||||
<ai-chat-panel
|
||||
ref="aiChatPanel"
|
||||
:split="railVisible"
|
||||
:store-name="currentStoreStore.currentStoreName"
|
||||
:session-key="sessionKey"
|
||||
:store-id="aiStoreId"
|
||||
@@ -30,6 +31,7 @@
|
||||
<t-empty v-else description="当前账号无权使用门店智能助手" />
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { useLayout } from "timi-tdesign-mobile";
|
||||
import { useUserStore } from "timi-web-api/store";
|
||||
import AiChatPanel from "@/pages/ai/components/AiChatPanel.vue";
|
||||
import { useCurrentStoreStore } from "@/store/currentStoreStore";
|
||||
@@ -39,6 +41,7 @@ defineOptions({
|
||||
name: "AiChatPage"
|
||||
});
|
||||
|
||||
const { railVisible } = useLayout({ tablet: true });
|
||||
const userStore = useUserStore();
|
||||
const currentStoreStore = useCurrentStoreStore();
|
||||
const conversationResetToken = ref(0);
|
||||
|
||||
@@ -1,4 +1,15 @@
|
||||
<template>
|
||||
<div class="chat-layout">
|
||||
<ai-conversation-list
|
||||
v-if="props.split"
|
||||
:visible="true"
|
||||
inline
|
||||
:active-conversation-id="conversationId"
|
||||
:disabled="isBusy"
|
||||
:session-key="props.sessionKey"
|
||||
@select="selectConversation"
|
||||
@delete="handleConversationDelete"
|
||||
/>
|
||||
<shared-ai-chat-panel
|
||||
ref="messageList"
|
||||
class="shared-panel"
|
||||
@@ -61,6 +72,7 @@
|
||||
</template>
|
||||
</shared-ai-chat-panel>
|
||||
<ai-conversation-list
|
||||
v-if="!props.split"
|
||||
v-model:visible="conversationVisible"
|
||||
:active-conversation-id="conversationId"
|
||||
:disabled="isBusy"
|
||||
@@ -68,6 +80,7 @@
|
||||
@select="selectConversation"
|
||||
@delete="handleConversationDelete"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
@@ -98,6 +111,7 @@ defineOptions({
|
||||
});
|
||||
|
||||
interface Props {
|
||||
split?: boolean;
|
||||
storeName: string;
|
||||
sessionKey: string;
|
||||
storeId?: string;
|
||||
@@ -430,3 +444,16 @@ onMounted(async () => {
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
<style scoped lang="less">
|
||||
.chat-layout {
|
||||
height: 100%;
|
||||
display: flex;
|
||||
min-height: 0;
|
||||
|
||||
.shared-panel {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user