From fac2065ec6995ee8e51faba2fd8679c3f4233f5b Mon Sep 17 00:00:00 2001 From: wangdan-fit2cloud Date: Wed, 31 Jan 2024 15:19:12 +0800 Subject: [PATCH 1/5] feat: --- ui/src/components/ai-chat/index.vue | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ui/src/components/ai-chat/index.vue b/ui/src/components/ai-chat/index.vue index 6492de5ed..f2fddd952 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', @@ -288,11 +288,13 @@ function getChartOpenId() { applicationApi .getChatOpen(props.appId) .then((res) => { + console.log(res) chartOpenId.value = res.data chatMessage() }) .catch((res) => { - if (res.response.status === 401) { + console.log(res) + if (res.code === 401 || res.response.status === 401) { application.asyncAppAuthentication(accessToken).then(() => { getChartOpenId() }) From 8ede3e82a535f747508abc29be3f5a55525c6b5c Mon Sep 17 00:00:00 2001 From: wangdan-fit2cloud Date: Wed, 31 Jan 2024 16:23:30 +0800 Subject: [PATCH 2/5] =?UTF-8?q?fix:=20401=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ui/package.json | 2 +- ui/src/components/ai-chat/index.vue | 42 ++++++++++++++++------------- 2 files changed, 25 insertions(+), 19 deletions(-) diff --git a/ui/package.json b/ui/package.json index d5fe95064..774b1c467 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 f2fddd952..07bb9b642 100644 --- a/ui/src/components/ai-chat/index.vue +++ b/ui/src/components/ai-chat/index.vue @@ -288,13 +288,12 @@ function getChartOpenId() { applicationApi .getChatOpen(props.appId) .then((res) => { - console.log(res) chartOpenId.value = res.data chatMessage() }) .catch((res) => { console.log(res) - if (res.code === 401 || res.response.status === 401) { + if (res.response.status === 403) { application.asyncAppAuthentication(accessToken).then(() => { getChartOpenId() }) @@ -407,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) From 4fd78e5b7969f125942af835660c9241aeb0c93a Mon Sep 17 00:00:00 2001 From: wangdan-fit2cloud Date: Wed, 31 Jan 2024 16:38:58 +0800 Subject: [PATCH 3/5] =?UTF-8?q?fix:=20=E5=85=BC=E5=AE=B9=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ui/src/components/login-layout/index.vue | 33 ++++++++++-------------- 1 file changed, 13 insertions(+), 20 deletions(-) diff --git a/ui/src/components/login-layout/index.vue b/ui/src/components/login-layout/index.vue index 120ed6815..c8e33646e 100644 --- a/ui/src/components/login-layout/index.vue +++ b/ui/src/components/login-layout/index.vue @@ -2,15 +2,8 @@