From f41dcb79dbdc1dfa83c15cb54650bed7f13999dc Mon Sep 17 00:00:00 2001 From: cc500 <2014434568@qq.com> Date: Thu, 13 Feb 2025 18:21:14 +0800 Subject: [PATCH 1/2] test --- src/components/dialoguePanel/DialoguePanel.vue | 16 ++++++++++++++-- src/components/dialoguePanel/DialogueThought.vue | 3 +++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/components/dialoguePanel/DialoguePanel.vue b/src/components/dialoguePanel/DialoguePanel.vue index 4154c27e..c816c013 100644 --- a/src/components/dialoguePanel/DialoguePanel.vue +++ b/src/components/dialoguePanel/DialoguePanel.vue @@ -249,10 +249,22 @@ const contentAfterMark = computed(() => { if(tableStart!== -1){ str = str.slice(0, tableStart) + '
' + str.slice(tableStart, str.indexOf('') + ''.length).replace('', '
') + str.slice(str.indexOf('') + ''.length); } + str = str + '

1212121212

eqwewqewqeqewqewq
' //仅获取第一个遇到的 think 标签 - if(str.match(/([\s\S]*?)<\/think>/)){ - thoughtContent.value = str.match(/([\s\S]*?)<\/think>/)[1]; + // if(str.match(/([\s\S]*?)<\/think>/)){ + // thoughtContent.value = str.match(/([\s\S]*?)<\/think>/)[1]; + // } + let thinkStart = str.indexOf(''); + if (thinkStart !== -1) { + let thinkEnd = str.indexOf('', thinkStart); + if (thinkEnd !== -1) { + // 提取 标签中的内容 + thoughtContent.value = str.slice(thinkStart + 7, thinkEnd); + // 将 标签替换为空 + str = str.slice(0, thinkStart) + str.slice(thinkEnd + 8); + } } + //将标签替换为空 return str.replace(/([\s\S]*?)<\/think>/g,''); }); diff --git a/src/components/dialoguePanel/DialogueThought.vue b/src/components/dialoguePanel/DialogueThought.vue index ef948fb1..17241a24 100644 --- a/src/components/dialoguePanel/DialogueThought.vue +++ b/src/components/dialoguePanel/DialogueThought.vue @@ -34,8 +34,11 @@ const contentAfterMark = computed(() => { if (!props.content) { return ''; } + console.log(props.content); //xxs将大于号转为html实体以防歧义;将< >替换为正常字符; let str = marked.parse(xss(props.content).replace(/>/g, '>').replace(/</g, '<')); + console.log(str); + return str; }); -- Gitee From 0b7f5f35bc7137975feebd099efe06db677b366b Mon Sep 17 00:00:00 2001 From: cc500 <2014434568@qq.com> Date: Thu, 13 Feb 2025 18:23:04 +0800 Subject: [PATCH 2/2] test --- src/components/dialoguePanel/DialoguePanel.vue | 1 - 1 file changed, 1 deletion(-) diff --git a/src/components/dialoguePanel/DialoguePanel.vue b/src/components/dialoguePanel/DialoguePanel.vue index c816c013..947990a3 100644 --- a/src/components/dialoguePanel/DialoguePanel.vue +++ b/src/components/dialoguePanel/DialoguePanel.vue @@ -249,7 +249,6 @@ const contentAfterMark = computed(() => { if(tableStart!== -1){ str = str.slice(0, tableStart) + '
' + str.slice(tableStart, str.indexOf('') + ''.length).replace('', '
') + str.slice(str.indexOf('') + ''.length); } - str = str + '

1212121212

eqwewqewqeqewqewq
' //仅获取第一个遇到的 think 标签 // if(str.match(/([\s\S]*?)<\/think>/)){ // thoughtContent.value = str.match(/([\s\S]*?)<\/think>/)[1]; -- Gitee