|
@@ -1,5 +1,5 @@
|
|
<script setup>
|
|
<script setup>
|
|
-import { ref, unref, computed, onMounted, onUnmounted, h } from 'vue';
|
|
|
|
|
|
+import { ref, unref, computed, onUnmounted, h } from 'vue';
|
|
import { useMessage, NDatePicker, NTabs, NTab, NRadioGroup, NRadio, NCheckboxGroup, NCheckbox, NDataTable } from 'naive-ui';
|
|
import { useMessage, NDatePicker, NTabs, NTab, NRadioGroup, NRadio, NCheckboxGroup, NCheckbox, NDataTable } from 'naive-ui';
|
|
import { BaseButton, RecodeCardItem, TheSubMenu, TheChatView, ChatWelcome, SvgIcon } from '@/components';
|
|
import { BaseButton, RecodeCardItem, TheSubMenu, TheChatView, ChatWelcome, SvgIcon } from '@/components';
|
|
import { ChatAsk, ChatAnswer } from '@/components/Chat';
|
|
import { ChatAsk, ChatAnswer } from '@/components/Chat';
|
|
@@ -18,6 +18,7 @@ const { scrollRef, scrollToBottom, scrollToBottomIfAtBottom } = useScroll();
|
|
const { chatDataSource, addChat, updateChat, clearChat, updateById } = useChat();
|
|
const { chatDataSource, addChat, updateChat, clearChat, updateById } = useChat();
|
|
|
|
|
|
let controller = new AbortController();
|
|
let controller = new AbortController();
|
|
|
|
+let timer = null;
|
|
|
|
|
|
const ANSWER_ID_KEY = '@@id@@';
|
|
const ANSWER_ID_KEY = '@@id@@';
|
|
|
|
|
|
@@ -54,6 +55,20 @@ const resetFormData = () => {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+const resetState = () => {
|
|
|
|
+ tabActive.value = 'daily';
|
|
|
|
+
|
|
|
|
+ currenSessionId.value = null;
|
|
|
|
+
|
|
|
|
+ recordActive.value = null;
|
|
|
|
+
|
|
|
|
+ reportDate.value = null;
|
|
|
|
+
|
|
|
|
+ resetFormData();
|
|
|
|
+
|
|
|
|
+ clearChat();
|
|
|
|
+}
|
|
|
|
+
|
|
// 新建对话
|
|
// 新建对话
|
|
const handleCreateDialog = async () => {
|
|
const handleCreateDialog = async () => {
|
|
message.destroyAll();
|
|
message.destroyAll();
|
|
@@ -65,16 +80,8 @@ const handleCreateDialog = async () => {
|
|
if (!unref(chatDataSource).length) {
|
|
if (!unref(chatDataSource).length) {
|
|
return message.info('已切换最新会话');
|
|
return message.info('已切换最新会话');
|
|
}
|
|
}
|
|
-
|
|
|
|
- tabActive.value = 'daily';
|
|
|
|
|
|
|
|
- currenSessionId.value = null;
|
|
|
|
-
|
|
|
|
- recordActive.value = null;
|
|
|
|
-
|
|
|
|
- resetFormData();
|
|
|
|
-
|
|
|
|
- clearChat();
|
|
|
|
|
|
+ resetState();
|
|
}
|
|
}
|
|
|
|
|
|
// 查询对话详情
|
|
// 查询对话详情
|
|
@@ -110,6 +117,7 @@ const handleChatDetail = async ({ sessionId }) => {
|
|
scrollToBottom();
|
|
scrollToBottom();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+// 请求
|
|
const onRegenerate = async (question, options) => {
|
|
const onRegenerate = async (question, options) => {
|
|
controller = new AbortController();
|
|
controller = new AbortController();
|
|
|
|
|
|
@@ -202,7 +210,7 @@ const handleSubmit = async (question, params) => {
|
|
innerLoading: true,
|
|
innerLoading: true,
|
|
});
|
|
});
|
|
|
|
|
|
- setTimeout(() => {
|
|
|
|
|
|
+ timer = setTimeout(() => {
|
|
|
|
|
|
updateChat({
|
|
updateChat({
|
|
...chatDataSourceItem.value,
|
|
...chatDataSourceItem.value,
|
|
@@ -320,6 +328,13 @@ const formatData = (data) => {
|
|
}).filter(Boolean);
|
|
}).filter(Boolean);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+// 返回
|
|
|
|
+const handleback = async () => {
|
|
|
|
+ clearInterval(timer);
|
|
|
|
+ await chatApi.getStopChatStream(currenSessionId.value);
|
|
|
|
+ resetState();
|
|
|
|
+}
|
|
|
|
+
|
|
// 删除历史对话
|
|
// 删除历史对话
|
|
const handeChatDelete = async (id) => {
|
|
const handeChatDelete = async (id) => {
|
|
await chatApi.deleteHistory(id);
|
|
await chatApi.deleteHistory(id);
|
|
@@ -350,9 +365,6 @@ const dateEndDisabled = (timestamp) => {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-onMounted(() => {
|
|
|
|
-})
|
|
|
|
-
|
|
|
|
onUnmounted(() => {
|
|
onUnmounted(() => {
|
|
controller.abort();
|
|
controller.abort();
|
|
Object.keys(chartInstance).forEach(key => chartInstance[key].clear());
|
|
Object.keys(chartInstance).forEach(key => chartInstance[key].clear());
|
|
@@ -378,7 +390,7 @@ onUnmounted(() => {
|
|
</div>
|
|
</div>
|
|
</TheSubMenu>
|
|
</TheSubMenu>
|
|
|
|
|
|
- <TheChatView ref="scrollRef" :is-footer="false">
|
|
|
|
|
|
+ <TheChatView ref="scrollRef" :is-footer="false" :is-back-btn="!!chatDataSource.length" @on-click-back="handleback">
|
|
<ChatWelcome title="您好,我是LibraAI智慧工单助手" :sub-title="[
|
|
<ChatWelcome title="您好,我是LibraAI智慧工单助手" :sub-title="[
|
|
'基于大语言模型的智能工单分析助手,可以为您实现数据分析及数据解读',
|
|
'基于大语言模型的智能工单分析助手,可以为您实现数据分析及数据解读',
|
|
'选择日期并为您生成日报分析'
|
|
'选择日期并为您生成日报分析'
|