[前端] 研读模块改造为三栏布局:文件树+预览+问答
This commit is contained in:
@@ -47,7 +47,7 @@
|
||||
</template>
|
||||
|
||||
<script setup lang='ts'>
|
||||
import {inject, onMounted, reactive, ref} from "vue";
|
||||
import {inject, onMounted, reactive, ref, watch, type Ref} from "vue";
|
||||
import {
|
||||
deleteChatMessageById,
|
||||
delHistoryChatById,
|
||||
@@ -62,6 +62,9 @@ import ReadingCreateMessage from "@/components/ReadingCreateMessage.vue";
|
||||
import {withLoading} from "@/utils/loading";
|
||||
import {ElMessage} from "element-plus";
|
||||
import {debounce} from "@/utils";
|
||||
|
||||
const selectedFile = inject('selectedFile') as Ref<any>;
|
||||
|
||||
// 引用内容
|
||||
const quoteMsg = inject("quoteMsg");
|
||||
const updateQuoteMsg = inject("updateQuoteMsg");
|
||||
@@ -79,7 +82,6 @@ const sendStatus = ref(false);
|
||||
const chatStatus = ref(false);
|
||||
const chatNumber = ref(0);
|
||||
const chatId = ref('');
|
||||
const historyParam = history.state;
|
||||
const conversationId = ref('');
|
||||
const chatInfo = reactive([]);
|
||||
let controller = null;
|
||||
@@ -143,7 +145,7 @@ const getFetchChatAPI = async (prompt) => {
|
||||
const chatData = {
|
||||
prompt,
|
||||
type: 99,
|
||||
fileId: historyParam.fileId
|
||||
fileId: selectedFile.value?.fileId
|
||||
};
|
||||
try {
|
||||
const fetchChatAPIData = await fetchChatAPI(chatData);
|
||||
@@ -196,10 +198,10 @@ const getFetchChatAPIProcess = async (type: string) => {
|
||||
headers: headers,
|
||||
signal: controller.signal,
|
||||
body: JSON.stringify({
|
||||
fileNames: [historyParam.embeddingId],
|
||||
fileNames: [selectedFile.value?.embeddingId],
|
||||
conversationId: conversationId.value,
|
||||
promptName: "default",
|
||||
knowledgeBaseIdList: [historyParam.folderId],
|
||||
knowledgeBaseIdList: [selectedFile.value?.folderId],
|
||||
chatType: type,
|
||||
quote: quoteMsg.value
|
||||
}),
|
||||
@@ -313,15 +315,21 @@ const autoPositionToBottom = () => {
|
||||
element.scrollTop = element.scrollHeight + 55;
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
//请求文件对话的dataId
|
||||
const loadChatHistory = async () => {
|
||||
// 重置对话状态
|
||||
chatInfo.length = 0;
|
||||
chatId.value = '';
|
||||
firstChat.value = true;
|
||||
chatNumber.value = 0;
|
||||
conversationId.value = '';
|
||||
|
||||
if (!selectedFile.value?.fileId) return;
|
||||
|
||||
try {
|
||||
let hisResponse = await listFileChatHistory(historyParam.fileId);
|
||||
//根据dataId请求获取历史记录
|
||||
let hisResponse = await listFileChatHistory(selectedFile.value.fileId);
|
||||
if (hisResponse.code == 200 && hisResponse.data) {
|
||||
chatNumber.value = hisResponse.data;
|
||||
firstChat.value = false;
|
||||
//请求文件对话的dataId
|
||||
let historyList = await listChatMessage({
|
||||
chatNumber: chatNumber.value,
|
||||
fileType: 1
|
||||
@@ -358,9 +366,17 @@ onMounted(async () => {
|
||||
}
|
||||
}
|
||||
} catch (error: any) {
|
||||
ElMessage.error(error && error.message ? error.message : '未知错误');
|
||||
// 新文件没有历史记录,不报错
|
||||
}
|
||||
};
|
||||
|
||||
// 监听文件切换,重新加载对话历史
|
||||
watch(() => selectedFile.value?.fileId, () => {
|
||||
loadChatHistory();
|
||||
});
|
||||
|
||||
onMounted(async () => {
|
||||
await loadChatHistory();
|
||||
handleReadingMessageContentScroll();
|
||||
})
|
||||
let messageInstance = null;
|
||||
|
||||
Reference in New Issue
Block a user