mirror of
http://112.124.100.131/ebiz-ai/ebiz-base-ai.git
synced 2025-12-07 01:46:48 +08:00
feat: 修复显示异常的问题
This commit is contained in:
@@ -233,7 +233,7 @@ export default {
|
||||
}
|
||||
if (this.single) {
|
||||
// this.$set(this.messages, this.messages.length - 1, { ...this.currentMessage })
|
||||
this.$set(this.messages, this.messages.length, this.genMessage = { ...this.currentMessage })
|
||||
this.$set(this.messages, this.messages.length - 1, this.genMessage = { ...this.currentMessage })
|
||||
} else {
|
||||
this.messages.push(this.currentMessage)
|
||||
}
|
||||
@@ -376,7 +376,7 @@ export default {
|
||||
// console.log(this.messages);
|
||||
|
||||
const chars = Array.from(chunk.answer)
|
||||
|
||||
|
||||
const isThink = chunk.isThink
|
||||
// 内部递归函数,用于逐字输出当前块
|
||||
const outputChar = () => {
|
||||
@@ -388,12 +388,11 @@ export default {
|
||||
const char = chars.shift() || ''
|
||||
// this.$set(this.currentMessage, isThink ? 'think' : 'text', this.currentMessage[isThink ? 'think' : 'text'] + char)
|
||||
if (requestIndex === 2) {
|
||||
console.log('requestIndex === 2', char);
|
||||
|
||||
// console.log('requestIndex === 2', char);
|
||||
this.$set(this.genMessage, 'text', this.genMessage.text + char)
|
||||
// this.messages.splice(this.messages.length - 1, 1, this.genMessage)
|
||||
} if (requestIndex === 1) {
|
||||
console.log('requestIndex === 1', char);
|
||||
// console.log('requestIndex === 1', char);
|
||||
|
||||
this.$set(this.currentMessage, 'text', this.currentMessage.text + char)
|
||||
}
|
||||
@@ -427,6 +426,8 @@ export default {
|
||||
sendMessage() {
|
||||
this.$emit('update:messageStatus', 'send')
|
||||
this.$emit('update:autoScrollEnabled', true)
|
||||
// 重置索引
|
||||
this.requestIndex = 1
|
||||
this.axiosGetAiChat()
|
||||
},
|
||||
|
||||
|
||||
@@ -20,8 +20,8 @@
|
||||
<p v-html="md.render(message.think)" v-if="message.think && message.showThink" class="thinkText" />
|
||||
</span>
|
||||
<div style="width: 100%">
|
||||
{{ (message) }}
|
||||
<!-- {{ filterVisible(message) }} -->
|
||||
<!-- {{ (message) }} -->
|
||||
{{ filterVisible(message) }}
|
||||
<!-- <hr> -->
|
||||
<p v-html="render(message)" class="render-container"></p>
|
||||
<span class="speakLoadingToast pv10" v-if="!filterVisible(message)">
|
||||
@@ -89,28 +89,20 @@ export default {
|
||||
},
|
||||
filterVisible(message) {
|
||||
// if (!message.text.startsWith('<')) {
|
||||
let text = message.text
|
||||
let text = message.text.trim()
|
||||
// 如果开头是中文,直接返回
|
||||
if (new RegExp('^[\u4e00-\u9fa5]+', 'g').test(text)) return text
|
||||
|
||||
text = text.replace(/<information>([^<]*)(?:<\/information>)?/g, '')
|
||||
text = text.replace(/<is_complete>([^<]*)(?:<\/is_complete>)?/g, '')
|
||||
|
||||
text = text.replace(/<information>([^<]*)(?:<\/information>)?/g, '').trim()
|
||||
text = text.replace(/<is_complete>([^<]*)(?:<\/is_complete>)?/g, '').trim()
|
||||
|
||||
// 捕获 不包含 < 的后置标签 span> /span> a</span>
|
||||
text = text.replace(/^[/]?[a-zA-z0-9]+[</\w>]+/g, '')
|
||||
// 尝试匹配 </abc> 标签
|
||||
text = text.replace(/^<\w+>/g, '')
|
||||
// <\/?([\w\s]+)?(?!>)$
|
||||
text = text.replace(/<\/?([\w\s='"]+)?(?!>)$/g, '')
|
||||
|
||||
text = text.replace(/^\w+/, "")
|
||||
text = text.replace(/^[/]?[a-zA-z0-9]+[</\w>]+/g, '').trim()
|
||||
// // 尝试匹配 </abc> 标签
|
||||
text = text.replace(/^<\w+>/g, '').trim()
|
||||
text = text.replace(/^\w+/, "").trim()
|
||||
text = text.replace(/<\/?([\w\s='"]+)?(?!>)$/gi, '').trim()
|
||||
return text
|
||||
// }
|
||||
// 只把 text 标签内容渲染
|
||||
// let match = /<text>([^<]*)(?:<\/text>)?/.exec(message.text)
|
||||
// let text = match ? match[1] : ''
|
||||
// text = text.replace(/<\/?([\w\s='"]+)?(?!>)$/g, '')
|
||||
// return text
|
||||
},
|
||||
showThink(message) {
|
||||
this.$set(message, 'showThink', !message.showThink)
|
||||
|
||||
Reference in New Issue
Block a user