style: markdown返回pre标签换行

This commit is contained in:
rd
2025-09-02 10:10:03 +08:00
parent 6a882309f9
commit ef8c10c056
2 changed files with 47 additions and 44 deletions

View File

@ -106,7 +106,7 @@ export default function useChatHandler(options: UseChatHandlerOptions): UseChatH
variant: 'borderless', variant: 'borderless',
style: ROLE_STYLE, style: ROLE_STYLE,
messageRender: (message: string) => { messageRender: (message: string) => {
return <div class="max-w-400px" v-html={md.render(message)} />; return <div class="max-w-400px markdown-wrap" v-html={md.render(message)} />;
}, },
footer: (params) => { footer: (params) => {
const { content, item } = params as { content: string; item: MESSAGE.Answer }; const { content, item } = params as { content: string; item: MESSAGE.Answer };
@ -223,7 +223,7 @@ export default function useChatHandler(options: UseChatHandlerOptions): UseChatH
const { node, output, runStatus, isCollapse = true, customRender, teamRunTaskId } = data; const { node, output, runStatus, isCollapse = true, customRender, teamRunTaskId } = data;
const isRulCompleted = runStatus === EnumTeamRunStatus.RunCompleted; const isRulCompleted = runStatus === EnumTeamRunStatus.RunCompleted;
let outputEleClass: string = `thought-chain-output border-l-#E6E6E8 border-l-1px pl-12px relative left-8px mb-4px`; let outputEleClass: string = `thought-chain-output border-l-#E6E6E8 border-l-1px pl-12px relative left-8px mb-4px markdown-wrap`;
!isLastRunTask(data) && (outputEleClass += ' hasLine pb-12px pt-4px'); !isLastRunTask(data) && (outputEleClass += ' hasLine pb-12px pt-4px');
return ( return (
@ -289,7 +289,7 @@ export default function useChatHandler(options: UseChatHandlerOptions): UseChatH
output: data.output, output: data.output,
role: ANSWER_ROLE, role: ANSWER_ROLE,
messageRender: (data: MESSAGE.Answer) => { messageRender: (data: MESSAGE.Answer) => {
return <div v-html={md.render(data.output ?? '')} />; return <div v-html={md.render(data.output ?? '')} class="markdown-wrap" />;
}, },
}); });
}; };
@ -328,7 +328,7 @@ export default function useChatHandler(options: UseChatHandlerOptions): UseChatH
_targetTask.content.customRender = () => { _targetTask.content.customRender = () => {
return ( return (
<> <>
<div v-html={md.render(output)} /> <div v-html={md.render(output)} class="markdown-wrap" />
{_targetData && ( {_targetData && (
<div class="file-card mt-10px"> <div class="file-card mt-10px">
<IconFile class="w-24px h-24px mr-16px color-#6D4CFE" /> <IconFile class="w-24px h-24px mr-16px color-#6D4CFE" />

View File

@ -29,30 +29,6 @@
flex-direction: row-reverse; flex-direction: row-reverse;
} }
.thought-chain-item {
position: relative;
margin: 0;
font-size: 12px;
list-style: none;
.thought-chain-output {
position: relative;
&.hasLine {
&::before {
content: '';
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
border-left: 1px solid #e6e6e8;
}
}
}
}
.xt-bubble-avatar {
}
.xt-bubble-content { .xt-bubble-content {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
@ -104,7 +80,33 @@
border-radius: 4px; border-radius: 4px;
} }
:deep(table) { .thought-chain-item {
position: relative;
margin: 0;
font-size: 12px;
list-style: none;
.thought-chain-output {
position: relative;
&.hasLine {
&::before {
content: '';
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
border-left: 1px solid #e6e6e8;
}
}
}
}
// 设置markdown返回的标签样式
:deep(.markdown-wrap) {
pre {
white-space: normal;
}
table {
border-collapse: collapse; border-collapse: collapse;
thead { thead {
tr { tr {
@ -127,6 +129,7 @@
} }
} }
} }
}
.action-box { .action-box {
cursor: pointer; cursor: pointer;