fix(chat): 固资回复表单字段太多时滑动优化

This commit is contained in:
runny committed 2026-06-10 14:02:35 +08:00
1 parent 8a0a7fd6ed
commit c01ddb8b23
1 file changed
+28 -5
+28 -5
View File
@@ -349,7 +349,11 @@ const renderMarkdown = (text: string) => {
const displayText = sanitizeShippingConversationText(stripReasoningPrelude(stripped));
try {
// 把 # 标题、代码块、[链接](url) 等 Markdown 解析成 HTML
return marked.parse(displayText);
const rendered = marked.parse(displayText);
const html = typeof rendered === 'string' ? rendered : displayText;
return html.replace(/<table\b[\s\S]*?<\/table>/gi, (tableHtml: string) => (
`<div class="chat-table-scroll"><div class="chat-table-inner">${tableHtml}</div></div>`
));
} catch (e) {
return displayText;
}
@@ -4908,7 +4912,7 @@ const showChatRating = ref(false);
</div>
<div
v-else
class="chat-markdown prose prose-sm max-w-none leading-7 text-primary prose-a:text-blue-600 prose-p:my-1 prose-li:my-0.5 prose-ol:my-2 prose-ul:my-2 prose-headings:my-2 prose-hr:my-3 prose-code:rounded prose-code:bg-slate-100 prose-code:px-1 prose-code:text-blue-700 prose-pre:my-3 prose-pre:border prose-pre:border-slate-700 prose-pre:bg-slate-900 prose-pre:text-slate-100 prose-table:w-full prose-table:border-collapse prose-th:border prose-th:border-slate-200 prose-th:bg-slate-50 prose-th:px-3 prose-th:py-2 prose-th:text-left prose-td:border prose-td:border-slate-200 prose-td:px-3 prose-td:py-2"
class="chat-markdown prose prose-sm max-w-none leading-7 text-primary prose-a:text-blue-600 prose-p:my-1 prose-li:my-0.5 prose-ol:my-2 prose-ul:my-2 prose-headings:my-2 prose-hr:my-3 prose-code:rounded prose-code:bg-slate-100 prose-code:px-1 prose-code:text-blue-700 prose-pre:my-3 prose-pre:border prose-pre:border-slate-700 prose-pre:bg-slate-900 prose-pre:text-slate-100 prose-th:border prose-th:border-slate-200 prose-th:bg-slate-50 prose-th:px-3 prose-th:py-2 prose-th:text-left prose-td:border prose-td:border-slate-200 prose-td:px-3 prose-td:py-2"
@click="handleChatMarkdownClick"
v-html="renderMarkdown(msg.content)"
></div>
@@ -5652,10 +5656,28 @@ const showChatRating = ref(false);
</template>
<style scoped>
:deep(.chat-markdown table) {
width: 100%;
border-collapse: collapse;
:deep(.chat-markdown) {
max-width: 100%;
}
:deep(.chat-markdown .chat-table-scroll) {
max-width: 100%;
overflow-x: auto;
overflow-y: hidden;
margin: 0.75rem 0;
-webkit-overflow-scrolling: touch;
}
:deep(.chat-markdown .chat-table-inner) {
width: max-content;
min-width: 100%;
}
:deep(.chat-markdown table) {
width: max-content;
min-width: 100%;
border-collapse: collapse;
margin: 0;
font-size: 0.875rem;
}
@@ -5665,6 +5687,7 @@ const showChatRating = ref(false);
padding: 0.5rem 0.75rem;
text-align: left;
vertical-align: top;
white-space: nowrap;
}
:deep(.chat-markdown th) {