From 361d46d0e2a9c5f795f766ed819037faef612167 Mon Sep 17 00:00:00 2001 From: yinbangzhong <zhongbangyin@126.com> Date: 星期二, 27 八月 2024 09:23:31 +0800 Subject: [PATCH] bug fix --- src/views/sessionManager/index.vue | 148 +++++++++++++++++++++++++++++++++--------------- 1 files changed, 101 insertions(+), 47 deletions(-) diff --git a/src/views/sessionManager/index.vue b/src/views/sessionManager/index.vue index 2d252ee..a46713c 100644 --- a/src/views/sessionManager/index.vue +++ b/src/views/sessionManager/index.vue @@ -99,55 +99,101 @@ backgroundColor: theme === 'light' ? '#ffffff' : '#000000', }" - style="border: none; display: inline" - v-for="(item, tipIndex) in tipMatch(sessionDetail)" + style="border: none;" + v-for="(breakContent, breakIndex) in breakLine(sessionDetail.content)" > - <span v-if="tipIndex == 0"> - {{ sessionDetail.content.substring(0, item.index) }} - <a-tooltip - background-color="#3491FA" - :content=" - getTipContent(messagenList.reference, index) - " - > - <img - style="width: 20px; height: 20px" - :src="tipImage" - /> - </a-tooltip> - </span> - <span v-else> - {{ - sessionDetail.content.substring( - item.preIndex + item.item.length, - item.index - ) - }} - <a-tooltip - background-color="#3491FA" - :content=" - getTipContent(messagenList.reference, index) - " - > - <img - style="width: 20px; height: 20px" - :src="tipImage" - /> - </a-tooltip> - </span> - </div> - </a-card> - <a-card v-else> - <div - :class="{ chatItemAnswer: theme === 'light' }" - :style="{ + <div + :class="{ chatItemAnswer: theme === 'light' }" + :style="{ backgroundColor: theme === 'light' ? '#ffffff' : '#000000', }" + style="border: none;" + v-if="isExistTip(breakContent)"> + <div + :class="{ chatItemAnswer: theme === 'light' }" + :style="{ + backgroundColor: + theme === 'light' ? '#ffffff' : '#000000', + }" + style="border: none;" + v-for="(item, tipIndex) in tipMatch(breakContent)" + > + <span v-if="tipIndex == 0"> + {{ breakContent.substring(0, item.index) }} + <a-tooltip + background-color="#3491FA" + :content=" + getTipContent(messagenList.reference, index) + " + > + <img + style="width: 20px; height: 20px" + :src="tipImage" + /> + </a-tooltip> + </span> + <span v-else-if ="tipIndex == item.len - 1"> + {{ + breakContent.substring( + item.preIndex + item.item.length, + item.index + ) + }} + <a-tooltip + background-color="#3491FA" + :content=" + getTipContent(messagenList.reference, index) + " + > + <img + style="width: 20px; height: 20px" + :src="tipImage" + /> + </a-tooltip> + {{ + breakContent.substring(item.index+5) + }} + </span> + <span v-else> + {{ + breakContent.substring( + item.preIndex + item.item.length, + item.index + ) + }} + <a-tooltip + background-color="#3491FA" + :content=" + getTipContent(messagenList.reference, index) + " + > + <img + style="width: 20px; height: 20px" + :src="tipImage" + /> + </a-tooltip> + </span> + </div> + </div> + <div v-else> + {{ breakContent }} + </div> + </div> + </a-card> + <a-card v-else> + <a-textarea + readonly + auto-size + v-model="sessionDetail.content" + :class="{ chatItemAnswer: theme === 'light' }" + :style="{ + backgroundColor: + theme === 'light' ? '#ffffff' : '#000000', + }" style="border: none" > - {{ sessionDetail.content }} - </div> + </a-textarea> </a-card> </template> <!-- <div>{{ sessionDetail.role === 'assistant' }}</div> --> @@ -456,6 +502,7 @@ import docx from '@/views/dmx/knowledgeLib/components/docx.vue'; import excel from '@/views/dmx/knowledgeLib/components/excel.vue'; import txtPdf from '@/views/dmx/knowledgeLib/components/txtPdf.vue'; + import { is } from "immutable"; // const url = ref('../../assets/session/PDF.png'); @@ -539,13 +586,20 @@ } }; - const tipMatch = (session: any): any[] => { + const breakLine = (message: string): string[] => { + //鎸塡n鍒嗗壊瀛楃涓� + let arr = message.split('\n'); + return arr + } + + const tipMatch = (msg: string): any[] => { //match session.content涓殑##[0-9]$$鐨勭储寮� let indexs: any[] = []; let preTip = 0; - session.content.match(/##([0-9]+)\$\$/g)?.map((item) => { - let i = session.content.indexOf(item); - indexs.push({ index: i, item: item, preIndex: preTip }); + let matches=msg.match(/##([0-9]+)\$\$/g) + matches?.map((item) => { + let i = msg.indexOf(item); + indexs.push({ index: i, item: item, preIndex: preTip, len: matches.length }); preTip = i; }); return indexs; -- Gitblit v1.8.0