Skip to content

Commit 06a5f6a

Browse files
committed
fix: 处理回复中的html标签和内容
1 parent 2178a81 commit 06a5f6a

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

ui/src/components/ai-chat/component/operation-button/ChatOperationButton.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ function removeFormRander(text: string) {
156156
return text
157157
.replace('你好,请先填写下面表单内容:', '')
158158
.replace('请先填写以下表单并点击提交按钮', '')
159-
.replace(/<[^>]+>.*?<\/[^>]+>/gs, '')
159+
.replace(/<form_rander>[\s\S]*?<\/form_rander>/g, '')
160160
.replace('填写后请点击【提交】按钮进行提交。', '')
161161
.trim()
162162
}
@@ -165,10 +165,10 @@ const playAnswerText = (text: string) => {
165165
if (!text) {
166166
text = '抱歉,没有查找到相关内容,请重新描述您的问题或提供更多信息。'
167167
}
168-
// text 处理成纯文本
169-
text = markdownToPlainText(text)
170168
// 移除表单渲染器
171169
text = removeFormRander(text)
170+
// text 处理成纯文本
171+
text = markdownToPlainText(text)
172172
// console.log(text)
173173
audioPlayerStatus.value = true
174174
if (props.tts_type === 'BROWSER') {

ui/src/components/ai-chat/component/operation-button/LogOperationButton.vue

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ function removeFormRander(text: string) {
135135
return text
136136
.replace('你好,请先填写下面表单内容:', '')
137137
.replace('请先填写以下表单并点击提交按钮', '')
138-
.replace(/<[^>]+>.*?<\/[^>]+>/gs, '')
138+
.replace(/<form_rander>[\s\S]*?<\/form_rander>/g, '')
139139
.replace('填写后请点击【提交】按钮进行提交。', '')
140140
.trim()
141141
}
@@ -145,11 +145,11 @@ const playAnswerText = (text: string) => {
145145
if (!text) {
146146
text = '抱歉,没有查找到相关内容,请重新描述您的问题或提供更多信息。'
147147
}
148-
// text 处理成纯文本
149-
text = markdownToPlainText(text)
150148
// 移除表单渲染器
151149
text = removeFormRander(text)
152-
console.log(text)
150+
// text 处理成纯文本
151+
text = markdownToPlainText(text)
152+
// console.log(text)
153153
audioPlayerStatus.value = true
154154
if (props.tts_type === 'BROWSER') {
155155
if (text !== utterance.value?.text) {

0 commit comments

Comments
 (0)