diff --git a/ui/package.json b/ui/package.json index d5fe9506..774b1c46 100644 --- a/ui/package.json +++ b/ui/package.json @@ -14,7 +14,7 @@ }, "dependencies": { "axios": "^0.27.2", - "element-plus": "^2.4.3", + "element-plus": "^2.5.3", "install": "^0.13.0", "lodash": "^4.17.21", "markdown-it": "^13.0.2", diff --git a/ui/src/components/ai-chat/index.vue b/ui/src/components/ai-chat/index.vue index 6492de5e..07bb9b64 100644 --- a/ui/src/components/ai-chat/index.vue +++ b/ui/src/components/ai-chat/index.vue @@ -211,7 +211,7 @@ const prologueList = computed(() => { const temp = props.data?.prologue let arr: any = [] const lines = temp?.split('\n') - lines.forEach((str: string, index: number) => { + lines?.forEach((str: string, index: number) => { if (isMdArray(str)) { arr[index] = { type: 'question', @@ -292,7 +292,8 @@ function getChartOpenId() { chatMessage() }) .catch((res) => { - if (res.response.status === 401) { + console.log(res) + if (res.response.status === 403) { application.asyncAppAuthentication(accessToken).then(() => { getChartOpenId() }) @@ -405,26 +406,33 @@ function chatMessage() { record_id: '', vote_status: '-1' }) - chatList.value.push(chat) - inputValue.value = '' - nextTick(() => { - // 将滚动条滚动到最下面 - scrollDiv.value.setScrollTop(Number.MAX_SAFE_INTEGER) - }) // 对话 applicationApi .postChatMessage(chartOpenId.value, problem_text) .then((response) => { - ChatManagement.addChatRecord(chat, 50, loading) - ChatManagement.write(chat.id) - const reader = response.body.getReader() - // 处理流数据 - const write = getWrite( - chat, - reader, - response.headers.get('Content-Type') !== 'application/json' - ) - return reader.read().then(write) + console.log(response.status) + if (response.status === 401) { + application.asyncAppAuthentication(accessToken).then(() => { + chatMessage() + }) + } else { + chatList.value.push(chat) + inputValue.value = '' + nextTick(() => { + // 将滚动条滚动到最下面 + scrollDiv.value.setScrollTop(Number.MAX_SAFE_INTEGER) + }) + ChatManagement.addChatRecord(chat, 50, loading) + ChatManagement.write(chat.id) + const reader = response.body.getReader() + // 处理流数据 + const write = getWrite( + chat, + reader, + response.headers.get('Content-Type') !== 'application/json' + ) + return reader.read().then(write) + } }) .then(() => { return !props.appId && getSourceDetail(chat) diff --git a/ui/src/components/login-layout/index.vue b/ui/src/components/login-layout/index.vue index 120ed681..c8e33646 100644 --- a/ui/src/components/login-layout/index.vue +++ b/ui/src/components/login-layout/index.vue @@ -2,15 +2,8 @@