Skip to content

Commit d214e31

Browse files
authored
perf: 优化AI回答 #132 (#155)
1 parent 1a29199 commit d214e31

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

ui/src/api/type/application.ts

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -51,19 +51,23 @@ export class ChatRecordManage {
5151
this.loading.value = true
5252
}
5353
this.id = setInterval(() => {
54-
const s = this.chat.buffer.shift()
55-
if (s !== undefined) {
56-
this.chat.answer_text = this.chat.answer_text + s
54+
if (this.chat.buffer.length > 20) {
55+
this.chat.answer_text =
56+
this.chat.answer_text + this.chat.buffer.splice(0, this.chat.buffer.length - 20).join('')
57+
} else if (this.is_close) {
58+
this.chat.answer_text = this.chat.answer_text + this.chat.buffer.join('')
59+
this.chat.write_ed = true
60+
this.write_ed = true
61+
if (this.loading) {
62+
this.loading.value = false
63+
}
64+
if (this.id) {
65+
clearInterval(this.id)
66+
}
5767
} else {
58-
if (this.is_close) {
59-
this.chat.write_ed = true
60-
this.write_ed = true
61-
if (this.loading) {
62-
this.loading.value = false
63-
}
64-
if (this.id) {
65-
clearInterval(this.id)
66-
}
68+
const s = this.chat.buffer.shift()
69+
if (s !== undefined) {
70+
this.chat.answer_text = this.chat.answer_text + s
6771
}
6872
}
6973
}, this.ms)

0 commit comments

Comments
 (0)