From ae7075cc5ae082ed19b0e6ee2c627fc1160bff01 Mon Sep 17 00:00:00 2001 From: fromhsc Date: Mon, 17 Feb 2025 19:20:05 +0800 Subject: [PATCH 1/2] =?UTF-8?q?think=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/assets/images/flow_arrow.png | Bin 159 -> 190 bytes .../dialoguePanel/DialoguePanel.vue | 30 ++++++++---------- .../dialoguePanel/DialogueThought.vue | 11 +++---- 3 files changed, 17 insertions(+), 24 deletions(-) mode change 100755 => 100644 src/assets/images/flow_arrow.png diff --git a/src/assets/images/flow_arrow.png b/src/assets/images/flow_arrow.png old mode 100755 new mode 100644 index c59ee9391e65ec7a477f21f1e3b4e24ab7019957..944453bd2c0b5fd2dced4cf34e2ea349e1d726a0 GIT binary patch delta 162 zcmbQwxQ}syNVL(false); const txt2imgPathZoom = ref(''); // 解析完成后的文本内容 const contentAfterMark = computed(() => { - if (!props.content) { return ""; } @@ -250,22 +249,19 @@ const contentAfterMark = computed(() => { str = str.slice(0, tableStart) + '
' + str.slice(tableStart, str.indexOf('') + ''.length).replace('', '
') + str.slice(str.indexOf('') + ''.length); } //仅获取第一个遇到的 think 标签 - // 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); - } + const startIndex = str.indexOf(''); + const endIndex = str.indexOf(''); + if (startIndex !== -1 && endIndex === -1) { + // 计算 之后的字符串 + const contentAfterA = str.substring(startIndex + 7); // +2 是因为我们要跳过 这两个字符 + thoughtContent.value = contentAfterA; + console.log(thoughtContent.value); + return ""; } - - //将标签替换为空 - return str.replace(/([\s\S]*?)<\/think>/g,''); + else if(startIndex !== -1 && endIndex !== -1){ + thoughtContent.value = str.match(/([\s\S]*?)<\/think>/)[1]; + } + return str.replace(/([\s\S]*?)<\/think>/g,''); }); @@ -486,7 +482,7 @@ const handleSendMessage = async (question, user_selected_flow, user_selected_plu {{$t('history.cancel')}} -
+
{{$t('feedback.eulercopilot_is_thinking')}}
diff --git a/src/components/dialoguePanel/DialogueThought.vue b/src/components/dialoguePanel/DialogueThought.vue index 17241a2..91f0ca6 100644 --- a/src/components/dialoguePanel/DialogueThought.vue +++ b/src/components/dialoguePanel/DialogueThought.vue @@ -25,7 +25,7 @@ const props = defineProps({ required: true, }, }); -const isCollapsed = ref(true); +const isCollapsed = ref(false); const toggleCollapse = () => { isCollapsed.value = !isCollapsed.value; }; @@ -59,7 +59,6 @@ const contentAfterMark = computed(() => { background-color: #f8f8f8; .think-label { - font-size: 0.9rem; font-weight: bold; color: #666; position: absolute; @@ -72,20 +71,18 @@ const contentAfterMark = computed(() => { .collapse-control { display: flex; align-items: center; - + transform-origin: center center; .collapse-icon { width: 1.2rem; height: 1.2rem; transition: transform 0.3s ease; - + top: 6px; &.is-collapsed { + top: 5px; transform: rotate(-90deg); } } - .collapse-text { - margin-left: 0.5rem; - font-size: 0.9rem; color: #666; } } -- Gitee From 7fe31774f3347db3add492280c51a649aa05ae61 Mon Sep 17 00:00:00 2001 From: fromhsc Date: Mon, 17 Feb 2025 19:21:16 +0800 Subject: [PATCH 2/2] test --- src/components/dialoguePanel/DialoguePanel.vue | 1 - src/components/dialoguePanel/DialogueThought.vue | 3 --- 2 files changed, 4 deletions(-) diff --git a/src/components/dialoguePanel/DialoguePanel.vue b/src/components/dialoguePanel/DialoguePanel.vue index 370bf83..8882ae3 100644 --- a/src/components/dialoguePanel/DialoguePanel.vue +++ b/src/components/dialoguePanel/DialoguePanel.vue @@ -255,7 +255,6 @@ const contentAfterMark = computed(() => { // 计算
之后的字符串 const contentAfterA = str.substring(startIndex + 7); // +2 是因为我们要跳过 这两个字符 thoughtContent.value = contentAfterA; - console.log(thoughtContent.value); return ""; } else if(startIndex !== -1 && endIndex !== -1){ diff --git a/src/components/dialoguePanel/DialogueThought.vue b/src/components/dialoguePanel/DialogueThought.vue index 91f0ca6..17ebdd0 100644 --- a/src/components/dialoguePanel/DialogueThought.vue +++ b/src/components/dialoguePanel/DialogueThought.vue @@ -34,11 +34,8 @@ 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