Skip to content

Commit 2178a81

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

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,8 @@ function markdownToPlainText(md: string) {
155155
function removeFormRander(text: string) {
156156
return text
157157
.replace('你好,请先填写下面表单内容:', '')
158-
.replace(/<formrander>[\s\S]*?<\/formrander>/, '')
159-
.replace(/<form_rander>[\s\S]*?<\/form_rander>/, '')
158+
.replace('请先填写以下表单并点击提交按钮', '')
159+
.replace(/<[^>]+>.*?<\/[^>]+>/gs, '')
160160
.replace('填写后请点击【提交】按钮进行提交。', '')
161161
.trim()
162162
}
@@ -169,6 +169,7 @@ const playAnswerText = (text: string) => {
169169
text = markdownToPlainText(text)
170170
// 移除表单渲染器
171171
text = removeFormRander(text)
172+
// console.log(text)
172173
audioPlayerStatus.value = true
173174
if (props.tts_type === 'BROWSER') {
174175
if (text !== utterance.value?.text) {

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,8 @@ function markdownToPlainText(md: string) {
134134
function removeFormRander(text: string) {
135135
return text
136136
.replace('你好,请先填写下面表单内容:', '')
137-
.replace(/<formrander>[\s\S]*?<\/formrander>/, '')
138-
.replace(/<form_rander>[\s\S]*?<\/form_rander>/, '')
137+
.replace('请先填写以下表单并点击提交按钮', '')
138+
.replace(/<[^>]+>.*?<\/[^>]+>/gs, '')
139139
.replace('填写后请点击【提交】按钮进行提交。', '')
140140
.trim()
141141
}
@@ -149,6 +149,7 @@ const playAnswerText = (text: string) => {
149149
text = markdownToPlainText(text)
150150
// 移除表单渲染器
151151
text = removeFormRander(text)
152+
console.log(text)
152153
audioPlayerStatus.value = true
153154
if (props.tts_type === 'BROWSER') {
154155
if (text !== utterance.value?.text) {

0 commit comments

Comments
 (0)