Commit ba77e352 authored by 水玉婷's avatar 水玉婷
Browse files

feat:添加tips

parent 136d1a8c
...@@ -145,7 +145,7 @@ const getChatRecordList = async () => { ...@@ -145,7 +145,7 @@ const getChatRecordList = async () => {
}); });
if (res.data.code === 0) { if (res.data.code === 0) {
let { data = [], total = 0, totalInfo = {} } = res.data.data || []; let { data = [], total = 0, totalInfo = {} } = res.data.data || [];
historyList.value = (data || []).map((item) => ({ historyList.value = (data.reverse() || []).map((item) => ({
...item, ...item,
isEdit: false, isEdit: false,
})); }));
......
...@@ -920,6 +920,27 @@ li { ...@@ -920,6 +920,27 @@ li {
// =============================================
// Tips消息样式
// =============================================
:deep(.message-tips) {
width: 100%;
max-width: 100%;
margin: 8px 0 -1px;
padding: 12px 16px;
border-bottom: none;
box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.05);
border-radius: 8px 8px 0 0;
position: relative;
background-color: @blue-light-2;
border-bottom: 1px solid @blue-light-3;
font-size: 14px;
color: @gray-7;
font-weight: 500;
line-height: 1.4;
}
// ============================================= // =============================================
// Markdown消息样式 // Markdown消息样式
// ============================================= // =============================================
...@@ -927,12 +948,29 @@ li { ...@@ -927,12 +948,29 @@ li {
:deep(.message-markdown) { :deep(.message-markdown) {
width: 100%; width: 100%;
max-width: 100%; max-width: 100%;
margin: 8px 0; margin: -1px 0 8px;
border-radius: 8px; border-radius: 0 0 8px 8px;
background-color: @white; background-color: @white;
border: 1px solid @blue-light-3; border: 1px solid @blue-light-3;
border-top: none;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1); box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
overflow: hidden; overflow: hidden;
// 当markdown与tips相邻时,调整间距
+ :deep(.message-tips) {
margin-top: 0;
border-top-left-radius: 0;
border-top-right-radius: 0;
border-top: none;
}
// 当tips在markdown之前时,调整markdown的样式
:deep(.message-tips) + & {
margin-top: 0;
border-top-left-radius: 0;
border-top-right-radius: 0;
border-top: none;
}
.markdown-content { .markdown-content {
padding: 12px 16px; padding: 12px 16px;
......
...@@ -11,6 +11,7 @@ import { markdownTemplate, isLastBlockMarkdown, getLastMarkdownBlockIndex, merge ...@@ -11,6 +11,7 @@ import { markdownTemplate, isLastBlockMarkdown, getLastMarkdownBlockIndex, merge
markdown: (content: any, isStreaming?: boolean) => string; markdown: (content: any, isStreaming?: boolean) => string;
option: (optionData: any) => string; option: (optionData: any) => string;
iframe: (iframeData: any) => string; iframe: (iframeData: any) => string;
tips: (content: string) => string;
} }
// 消息块类型定义 // 消息块类型定义
...@@ -197,6 +198,10 @@ export class ContentTemplateService { ...@@ -197,6 +198,10 @@ export class ContentTemplateService {
onerror="console.error('iframe加载失败:', this.src)" onerror="console.error('iframe加载失败:', this.src)"
></iframe> ></iframe>
</div>`; </div>`;
},
// tips标识模板
tips: (content: string) => {
return `<div class="message-tips">${content}</div>`;
} }
}; };
} }
...@@ -355,6 +360,18 @@ export class ContentTemplateService { ...@@ -355,6 +360,18 @@ export class ContentTemplateService {
} }
} }
break; break;
case 5: // tips标识数据
if (updatedResponse) {
// 使用tips模板创建新的内容块
updatedResponse.contentBlocks.push({
content: this.templates.tips(messageContent || ''),
hasThinkBox: false,
thinkContent: '',
thinkBoxExpanded: false,
});
}
break;
default: // 默认处理 default: // 默认处理
updatedResponse.contentBlocks.push({ updatedResponse.contentBlocks.push({
...@@ -448,7 +465,7 @@ export class ContentTemplateService { ...@@ -448,7 +465,7 @@ export class ContentTemplateService {
updatedBlockIndex = -1; updatedBlockIndex = -1;
break; break;
default: // 普通内容 case 0: // 普通内容
if (updatedIsThinking && updatedResponse) { if (updatedIsThinking && updatedResponse) {
if (updatedBlockIndex !== -1 && updatedResponse.contentBlocks[updatedBlockIndex]) { if (updatedBlockIndex !== -1 && updatedResponse.contentBlocks[updatedBlockIndex]) {
// 获取当前思考内容 // 获取当前思考内容
...@@ -465,32 +482,53 @@ export class ContentTemplateService { ...@@ -465,32 +482,53 @@ export class ContentTemplateService {
updatedResponse.contentBlocks[updatedBlockIndex].thinkBoxExpanded = defaultThinkBoxExpanded; updatedResponse.contentBlocks[updatedBlockIndex].thinkBoxExpanded = defaultThinkBoxExpanded;
} }
} else if (updatedResponse) { } else if (updatedResponse) {
// 检查最后一个块是否是普通文本块,如果是则合并,否则创建新块 // 特殊处理type=5的tips数据
const isLastText = isLastBlockText(updatedResponse.contentBlocks); if (contentType === 5) {
if (isLastText) {
// 合并到现有的普通文本块
const lastTextIndex = getLastTextBlockIndex(updatedResponse.contentBlocks);
if (lastTextIndex !== -1) {
updatedResponse.contentBlocks[lastTextIndex].content =
mergeTextContent(
updatedResponse.contentBlocks[lastTextIndex].content,
messageContent
);
}
} else {
// 创建新的内容块
updatedBlockIndex = updatedResponse.contentBlocks.length;
updatedResponse.contentBlocks.push({ updatedResponse.contentBlocks.push({
content: this.templates.text(messageContent), content: this.templates.tips(messageContent),
hasThinkBox: false, hasThinkBox: false,
thinkContent: '', thinkContent: '',
thinkBoxExpanded: false, thinkBoxExpanded: false,
}); });
} else {
// 检查最后一个块是否是普通文本块,如果是则合并,否则创建新块
const isLastText = isLastBlockText(updatedResponse.contentBlocks);
if (isLastText) {
// 合并到现有的普通文本块
const lastTextIndex = getLastTextBlockIndex(updatedResponse.contentBlocks);
if (lastTextIndex !== -1) {
updatedResponse.contentBlocks[lastTextIndex].content =
mergeTextContent(
updatedResponse.contentBlocks[lastTextIndex].content,
messageContent
);
}
} else {
// 创建新的内容块
updatedBlockIndex = updatedResponse.contentBlocks.length;
updatedResponse.contentBlocks.push({
content: this.templates.text(messageContent),
hasThinkBox: false,
thinkContent: '',
thinkBoxExpanded: false,
});
}
} }
} }
break; break;
default: // 其他状态码
if (updatedResponse) {
updatedResponse.contentBlocks.push({
content: this.templates.text(messageContent || ''),
hasThinkBox: false,
thinkContent: '',
thinkBoxExpanded: false,
});
}
break;
} }
return { return {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment