From d214e31f71bcd7a039a0b250360c1b2ed7273654 Mon Sep 17 00:00:00 2001 From: shaohuzhang1 <80892890+shaohuzhang1@users.noreply.github.com> Date: Thu, 18 Apr 2024 15:01:54 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E4=BC=98=E5=8C=96AI=E5=9B=9E=E7=AD=94?= =?UTF-8?q?=20#132=20(#155)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ui/src/api/type/application.ts | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/ui/src/api/type/application.ts b/ui/src/api/type/application.ts index 8cd8d5437..eefd8f31f 100644 --- a/ui/src/api/type/application.ts +++ b/ui/src/api/type/application.ts @@ -51,19 +51,23 @@ export class ChatRecordManage { this.loading.value = true } this.id = setInterval(() => { - const s = this.chat.buffer.shift() - if (s !== undefined) { - this.chat.answer_text = this.chat.answer_text + s + if (this.chat.buffer.length > 20) { + this.chat.answer_text = + this.chat.answer_text + this.chat.buffer.splice(0, this.chat.buffer.length - 20).join('') + } else if (this.is_close) { + this.chat.answer_text = this.chat.answer_text + this.chat.buffer.join('') + this.chat.write_ed = true + this.write_ed = true + if (this.loading) { + this.loading.value = false + } + if (this.id) { + clearInterval(this.id) + } } else { - if (this.is_close) { - this.chat.write_ed = true - this.write_ed = true - if (this.loading) { - this.loading.value = false - } - if (this.id) { - clearInterval(this.id) - } + const s = this.chat.buffer.shift() + if (s !== undefined) { + this.chat.answer_text = this.chat.answer_text + s } } }, this.ms)