From 6aff1559a73c66af77ea74c1e0b13075823a3812 Mon Sep 17 00:00:00 2001 From: xueyinfei <1207092115@qq.com> Date: Wed, 14 Jan 2026 15:44:58 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8A=A9=E6=89=8Bchatsessionid=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vue-fastapi-frontend/src/store/modules/user.js | 2 ++ vue-fastapi-frontend/src/utils/request.js | 1 + vue-fastapi-frontend/src/views/aichat/aichat.vue | 12 ++++++------ vue-fastapi-frontend/src/views/aichat/index.vue | 13 +++++++------ vue-fastapi-frontend/src/views/login.vue | 2 +- 5 files changed, 17 insertions(+), 13 deletions(-) diff --git a/vue-fastapi-frontend/src/store/modules/user.js b/vue-fastapi-frontend/src/store/modules/user.js index 3d8e084..1854eb7 100644 --- a/vue-fastapi-frontend/src/store/modules/user.js +++ b/vue-fastapi-frontend/src/store/modules/user.js @@ -86,6 +86,8 @@ const useUserStore = defineStore( removeToken() cache.local.remove('username') cache.local.remove('password') + cache.local.remove('chatSessionId') + cache.local.remove('waitingTotal') resolve() }).catch(error => { reject(error) diff --git a/vue-fastapi-frontend/src/utils/request.js b/vue-fastapi-frontend/src/utils/request.js index 3c2125d..e0614f7 100644 --- a/vue-fastapi-frontend/src/utils/request.js +++ b/vue-fastapi-frontend/src/utils/request.js @@ -169,6 +169,7 @@ service.interceptors.request.use(config => { } } } + config.timeout = 180000 return config }, error => { console.log(error) diff --git a/vue-fastapi-frontend/src/views/aichat/aichat.vue b/vue-fastapi-frontend/src/views/aichat/aichat.vue index 4638c4c..e55c94c 100644 --- a/vue-fastapi-frontend/src/views/aichat/aichat.vue +++ b/vue-fastapi-frontend/src/views/aichat/aichat.vue @@ -324,7 +324,7 @@ const upload = reactive({ headers: { Authorization: "Bearer " + getToken() }, // 上传的地址 url: import.meta.env.VITE_APP_BASE_API + "/aichat/upload", - data: {"sessionId":Cookies.get("chatSessionId")} + data: {"sessionId":cache.local.get("chatSessionId")} }); const isDisabledChart = computed( () => !(inputValue.value.trim()) @@ -345,7 +345,7 @@ function confirmReturn(item,index){ chatList.value.splice(index); let reqData = { "user_id": cache.local.get("username"), - "session_id": Cookies.get("chatSessionId"), + "session_id": cache.local.get("chatSessionId"), "checkpointer": item.checkpointer } sendChatMessage(reqData) @@ -532,7 +532,7 @@ function processAuth(data){ updateChatProcessData(updateData).then(res=>{ let reqData = { "user_id": cache.local.get("username"), - "session_id": Cookies.get("chatSessionId"), + "session_id": cache.local.get("chatSessionId"), "checkpointer": data.checkpointer, "action": data.action, "resume": true, @@ -559,7 +559,7 @@ async function sendChatHandle(event) { "type": "question", "content": inputValue.value.trim(), "time": formatDate(new Date()), - "sessionId": Cookies.get("chatSessionId"), + "sessionId": cache.local.get("chatSessionId"), "sessionName": chatList.value.length > 0 ? chatList.value[0].content.substring(0, 20) : inputValue.value.trim().substring(0, 20), "file": currentFiles.value } @@ -576,7 +576,7 @@ async function sendChatHandle(event) { "query": inputValue.value.trim(), "user_id": cache.local.get("username"), "robot": currentMachine.value.length > 0 ? currentMachine.value[0] : "", - "session_id": Cookies.get("chatSessionId"), + "session_id": cache.local.get("chatSessionId"), "doc": currentFiles.value } if (chatList.value.length > 0){ @@ -644,7 +644,7 @@ function sendChatMessage(data){ if (autoRequest){ let reqData = { "user_id": cache.local.get("username"), - "session_id": Cookies.get("chatSessionId"), + "session_id": cache.local.get("chatSessionId"), "checkpointer": answer.checkpointer, "action":"", "resume": true, diff --git a/vue-fastapi-frontend/src/views/aichat/index.vue b/vue-fastapi-frontend/src/views/aichat/index.vue index 3158aac..e25c331 100644 --- a/vue-fastapi-frontend/src/views/aichat/index.vue +++ b/vue-fastapi-frontend/src/views/aichat/index.vue @@ -84,6 +84,7 @@ import AiChat from './aichat.vue' import AutoTooltip from './auto-tooltip.vue' import { useRoute } from 'vue-router' import { listChatHistory, getChatList, DeleteChatSession } from "@/api/aichat/aichat"; +import cache from "../../plugins/cache.js"; const route = useRoute() const { proxy } = getCurrentInstance(); const { @@ -97,7 +98,7 @@ const AiChatRef = ref() const chatLogeData = ref([]) const show = ref(false) const currentRecordList = ref([]) -const sessionId = ref(Cookies.get("chatSessionId")) // 当前历史记录Id 默认为'new' +const sessionId = ref(cache.local.get("chatSessionId")) // 当前历史记录Id 默认为'new' const mouseId = ref('') const paginationConfig = reactive({ @@ -133,7 +134,7 @@ function showChatHistory(){ function newChat() { currentRecordList.value = [] sessionId.value = uuidv4() - Cookies.set("chatSessionId",sessionId.value) + cache.local.set("chatSessionId",sessionId.value) } function handleScroll(event) { @@ -153,7 +154,7 @@ function clickListHandle(item){ paginationConfig.current_page = 1 currentRecordList.value = [] sessionId.value = item.sessionId - Cookies.set("chatSessionId",sessionId.value) + cache.local.set("chatSessionId",sessionId.value) getChatRecord({sessionId: item.sessionId, pageNum: paginationConfig.current_page, pageSize: paginationConfig.page_size}) show.value = false } @@ -186,11 +187,11 @@ function getChatRecord(data){ watch(() => props.chatDataList, value => currentRecordList.value = JSON.parse(JSON.stringify(value))) onMounted( ()=>{ - if (Cookies.get("chatSessionId")){ + if (cache.local.get("chatSessionId")){ //调用子页面的赋值方法,给子页面赋值 - getChatRecord({sessionId: Cookies.get("chatSessionId"), pageNum: paginationConfig.current_page, pageSize: paginationConfig.page_size}) + getChatRecord({sessionId: cache.local.get("chatSessionId"), pageNum: paginationConfig.current_page, pageSize: paginationConfig.page_size}) }else { - Cookies.set("chatSessionId",uuidv4()) + cache.local.set("chatSessionId",uuidv4()) } } ) diff --git a/vue-fastapi-frontend/src/views/login.vue b/vue-fastapi-frontend/src/views/login.vue index 3c86b8a..068666f 100644 --- a/vue-fastapi-frontend/src/views/login.vue +++ b/vue-fastapi-frontend/src/views/login.vue @@ -129,7 +129,7 @@ function handleLogin() { }, {}); cache.local.set("username",loginForm.value.username) cache.local.set("password",md5(loginForm.value.password)) - Cookies.set("chatSessionId", 'new') + cache.local.remove("chatSessionId") router.push({ path: redirect.value || "/", query: otherQueryParams }); }).catch(() => { loading.value = false;