Browse Source

助手chatsessionid修复

master
xueyinfei 2 weeks ago
parent
commit
6aff1559a7
  1. 2
      vue-fastapi-frontend/src/store/modules/user.js
  2. 1
      vue-fastapi-frontend/src/utils/request.js
  3. 12
      vue-fastapi-frontend/src/views/aichat/aichat.vue
  4. 13
      vue-fastapi-frontend/src/views/aichat/index.vue
  5. 2
      vue-fastapi-frontend/src/views/login.vue

2
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)

1
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)

12
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,

13
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())
}
}
)

2
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;

Loading…
Cancel
Save