|
@@ -1,22 +1,61 @@
|
|
|
<script setup>
|
|
|
import { ref, reactive,onMounted } from 'vue';
|
|
|
import { NPopconfirm } from 'naive-ui';
|
|
|
-import { SvgIcon, BaseButton, BaseInput, RecodeCardItem, TheSubMenu, TheChatView } from '@/components';
|
|
|
-import { useInfinite } from '@/composables/useInfinite';
|
|
|
+import { SvgIcon, BaseButton, RecodeCardItem, TheSubMenu, TheChatView, ChatWelcome } from '@/components';
|
|
|
+import { ChatAsk, ChatAnswer, ChatInput } from '@/components/Chat';
|
|
|
import { chatApi } from '@/api/chat';
|
|
|
|
|
|
+import { useInfinite } from '@/composables/useInfinite';
|
|
|
+import { useScroll } from '@/composables/useScroll';
|
|
|
+import { useChat } from '@/composables/useChat';
|
|
|
+
|
|
|
// TODO: 如果这里的key不一样,将会在拆一层组件出来 - list
|
|
|
const { recordList, isFetching, onScrolltolower } = useInfinite({model: 0});
|
|
|
+const { scrollRef, scrollToBottom } = useScroll();
|
|
|
+const { chatDataSource, addChat } = useChat();
|
|
|
+
|
|
|
+// chat数据源
|
|
|
+// const chatDataSource = ref([]);
|
|
|
+const isLoading = ref(false);
|
|
|
+const activeSection = ref(null);
|
|
|
|
|
|
const switchModelState = ref(true);
|
|
|
|
|
|
onMounted(async () => {
|
|
|
+ // scrollToBottom();
|
|
|
})
|
|
|
|
|
|
// 新建对话
|
|
|
const handleCreateDialog = () => {
|
|
|
console.log("handleCreateDialog");
|
|
|
}
|
|
|
+
|
|
|
+// 查询对话详情
|
|
|
+const handleChatDetail = async ({ sessionId:sId }) => {
|
|
|
+ const { data } = await chatApi.getAnswerHistoryDetail({ sessionId:sId });
|
|
|
+ chatDataSource.value = data.map(({ createTime, sessionId, question, answer }) => ({ createTime, sessionId, question, answer }));
|
|
|
+ scrollToBottom();
|
|
|
+}
|
|
|
+
|
|
|
+// 提交问题
|
|
|
+const handleSubmit = inpVal => {
|
|
|
+
|
|
|
+ isLoading.value = true;
|
|
|
+
|
|
|
+ addChat({
|
|
|
+ sessionId: null,
|
|
|
+ question: inpVal,
|
|
|
+ answer: '',
|
|
|
+ })
|
|
|
+
|
|
|
+ setTimeout(() => {
|
|
|
+ isLoading.value = false;
|
|
|
+ }, 2000);
|
|
|
+
|
|
|
+ console.log("tempParams", tempParams);
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
</script>
|
|
|
|
|
|
<template>
|
|
@@ -30,110 +69,41 @@ const handleCreateDialog = () => {
|
|
|
</template>
|
|
|
|
|
|
<div class="pr-[4px] text-[#5e5e5e]">
|
|
|
- <RecodeCardItem v-for="item in recordList" :key="item.sessionId" v-bind="item" />
|
|
|
+ <RecodeCardItem
|
|
|
+ v-for="item in recordList"
|
|
|
+ :key="item.sessionId"
|
|
|
+ :title="item.question"
|
|
|
+ :time="item.createTime"
|
|
|
+ :data-item="item"
|
|
|
+ @on-click="handleChatDetail"
|
|
|
+ />
|
|
|
</div>
|
|
|
|
|
|
</TheSubMenu>
|
|
|
|
|
|
- <TheChatView>
|
|
|
- <div class="chat-welcome" v-show="switchModelState">
|
|
|
- <div class="
|
|
|
- welcome
|
|
|
- flex flex-col items-center justify-between
|
|
|
- text-center
|
|
|
- ">
|
|
|
- <SvgIcon name="common-logo" size="56"></SvgIcon>
|
|
|
- <p class="py-[10px] text-[#1A2029] text-[36px] font-bold leading-[50px]">您好,我是LibraAI专家问答</p>
|
|
|
- <p class="text-[#333333] leading-[20px]">期待与您一同规划和完成未来的工作。有任何重点或需讨论的事项,随时告诉我。</p>
|
|
|
- </div>
|
|
|
- <dl class="answer-list rounded-[8px] bg-white py-[30px] pl-[82px] mt-[36px]">
|
|
|
- <dt class="mb-[18px] text-[20px] text-[#1A2029] leading-[28px] font-bold">您可以试着问我:</dt>
|
|
|
- <dd class="mb-[19px] text-[15px] text-[#2E5CFF] leading-[21px] cursor-pointer hover:text-[#2E5CFF]/90">
|
|
|
- 帮我做一份如何快速入手污水处理厂的相关工作的学习计划?
|
|
|
- </dd>
|
|
|
- <dd class="mb-[19px] text-[15px] text-[#2E5CFF] leading-[21px] cursor-pointer hover:text-[#2E5CFF]/90">
|
|
|
- 硝化作用的速度快慢与哪些因素有关?</dd>
|
|
|
- <dd class="text-[15px] text-[#2E5CFF] leading-[21px] cursor-pointer hover:text-[#2E5CFF]/90">污泥回流比如何计算?</dd>
|
|
|
- </dl>
|
|
|
- </div>
|
|
|
-
|
|
|
- <div class="ask-inner" v-show="!switchModelState">
|
|
|
- <div class="chat-ask_icon">
|
|
|
- <SvgIcon name="chat-avatar" size="20" />
|
|
|
- </div>
|
|
|
- <p class="flex-1 pt-[6px] ml-[16px] text-[15px] font-bold leading-[24px]">帮我看一下COD现在的指标是什么,COD是什么意思?</p>
|
|
|
- </div>
|
|
|
-
|
|
|
- <div class="answer-inner">
|
|
|
- <div class="answer-card">
|
|
|
- <div class="chat-answer_icon">
|
|
|
- <SvgIcon name="common-logo" size="30" />
|
|
|
- </div>
|
|
|
- <p class="flex-1 pt-[6px] ml-[16px] text-[15px] leading-[24px]">
|
|
|
- COD,即化学需氧量,是衡量水中有机物质含量的重要指标。它反映了水中可氧化有机物的量,通常用来评估水体的污染程度。水中的有机物主要来源于工业废水、生活污水、农药残留等,这些有机物不仅会导致水质变差,还会对生物和人类健康产生负面影响。因此,通过测定COD值,可以了解水中有机污染物的含量,进而评估水体的污染程度。这对于制定环境保护政策、控制污染源、保障水资源安全等方面都具有重要的指导意义
|
|
|
- </p>
|
|
|
- </div>
|
|
|
- <ul class="answer-btn-group">
|
|
|
- <li class="btn">
|
|
|
- <SvgIcon name="chat-icon-copy" size="16" />
|
|
|
- </li>
|
|
|
- <li class="line"></li>
|
|
|
- <li class="btn">
|
|
|
- <SvgIcon name="chat-icon-yes" size="16" />
|
|
|
- </li>
|
|
|
- <li class="line"></li>
|
|
|
- <li class="btn">
|
|
|
- <SvgIcon name="chat-icon-no" size="16" />
|
|
|
- </li>
|
|
|
- </ul>
|
|
|
+ <TheChatView ref="scrollRef">
|
|
|
+ <ChatWelcome title="您好,我是LibraAI专家问答" card-title="您可以试着问我:"
|
|
|
+ :sub-title="[
|
|
|
+ '期待与您一同规划和完成未来的工作。有任何重点或需讨论的事项,随时告诉我。'
|
|
|
+ ]"
|
|
|
+ :card-content="[
|
|
|
+ '帮我做一份如何快速入手污水处理厂的相关工作的学习计划?',
|
|
|
+ '硝化作用的速度快慢与哪些因素有关?',
|
|
|
+ '污泥回流比如何计算?'
|
|
|
+ ]"
|
|
|
+ v-if="!chatDataSource.length"
|
|
|
+ />
|
|
|
+
|
|
|
+ <div class="conversation-item" v-if="chatDataSource.length">
|
|
|
+ <template v-for="item in chatDataSource" :key="item.sessionId">
|
|
|
+ <ChatAsk :content="item.question"></ChatAsk>
|
|
|
+ <ChatAnswer :content="item.answer" :loading="isLoading"></ChatAnswer>
|
|
|
+ </template>
|
|
|
</div>
|
|
|
|
|
|
<template #footer>
|
|
|
- <BaseInput></BaseInput>
|
|
|
+ <ChatInput @on-click="handleSubmit" @on-enter="handleSubmit" v-model:loading="isLoading"></ChatInput>
|
|
|
</template>
|
|
|
</TheChatView>
|
|
|
-
|
|
|
</section>
|
|
|
-</template>
|
|
|
-
|
|
|
-<style scoped lang="scss">
|
|
|
-
|
|
|
-.ask-inner {
|
|
|
- @include flex(x, start, start);
|
|
|
- padding-left: 20px;
|
|
|
- margin-bottom: 20px;
|
|
|
-}
|
|
|
-
|
|
|
-.answer-inner {
|
|
|
- margin-bottom: 20px;
|
|
|
- .answer-card {
|
|
|
- @include flex(x, start, start);
|
|
|
- padding: 20px;
|
|
|
- border-radius: 8px;
|
|
|
- background: #fff;
|
|
|
- }
|
|
|
-
|
|
|
- .answer-btn-group {
|
|
|
- @include flex(x, center, end);
|
|
|
- padding-top: 6px;
|
|
|
-
|
|
|
- .btn {
|
|
|
- @include flex(x, center, center);
|
|
|
- @include layout(28px, 28px, 4px);
|
|
|
- color: #89909B;
|
|
|
- cursor: pointer;
|
|
|
-
|
|
|
- &:hover {
|
|
|
- background: #DBEFFF;
|
|
|
- color: #2454FF;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- .line {
|
|
|
- @include layout(1px, 12px, 0);
|
|
|
- margin: 0 5px;
|
|
|
- background: #D3D0E1;
|
|
|
- }
|
|
|
- }
|
|
|
-}
|
|
|
-</style>
|
|
|
+</template>
|