From 883a3b6d27d8de17b644659f67ed8a4e09141863 Mon Sep 17 00:00:00 2001 From: shaohuzhang1 <80892890+shaohuzhang1@users.noreply.github.com> Date: Sun, 9 Feb 2025 22:11:04 +0800 Subject: [PATCH] fix: Opening remarks with built-in quick Q&A and tag conflicts result in HTML rendering failure (#2183) --- .../component/prologue-content/index.vue | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/ui/src/components/ai-chat/component/prologue-content/index.vue b/ui/src/components/ai-chat/component/prologue-content/index.vue index 2fa247d8e..77969ae49 100644 --- a/ui/src/components/ai-chat/component/prologue-content/index.vue +++ b/ui/src/components/ai-chat/component/prologue-content/index.vue @@ -32,7 +32,26 @@ const toQuickQuestion = (match: string, offset: number, input: string) => { } const prologue = computed(() => { const temp = props.available ? props.application?.prologue : t('chat.tip.prologueMessage') - return temp?.replace(/-\s.+/g, toQuickQuestion) + if (temp) { + const tag_list = [ + /[\d\D]*?<\/html_rander>/g, + /[\d\D]*?<\/echarts_rander>/g, + /[\d\D]*?<\/quick_question>/g, + /[\d\D]*?<\/form_rander>/g + ] + let _temp = temp + for (const index in tag_list) { + _temp = _temp.replaceAll(tag_list[index], '') + } + const quick_question_list = _temp.match(/-\s.+/g) + let result = temp + for (const index in quick_question_list) { + const quick_question = quick_question_list[index] + result = temp.replace(quick_question, toQuickQuestion) + } + return result + } + return '' })