fix(platform): 汇总知识库问答与图表展示修复
This commit is contained in:
1 parent
f615e56bb9
commit
87ea4ed8a9
41 files changed
+4569
-770
No files matched your search
@@ -5,7 +5,7 @@
|
||||
* 逻辑:由 ChatMessageList 按消息逐条挂载;合同审查结果卡自带边框,外层不再套 chat-msg-assistant 气泡以免双层框。
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
import { computed, nextTick, ref, watch } from 'vue';
|
||||
import { computed, nextTick, onMounted, ref, watch } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { Check, Copy, Download, Edit2, Eye, LayoutGrid, MessageSquareText, RotateCw, X } from 'lucide-vue-next';
|
||||
import { useAuthStore } from '@/features/auth/stores/auth.store';
|
||||
@@ -19,6 +19,7 @@ import TrainingExamQuestionMessage, { type TrainingHandlers } from './TrainingEx
|
||||
import TrainingVideoMessage from './TrainingVideoMessage.vue';
|
||||
import TrainingSummaryMessage from './TrainingSummaryMessage.vue';
|
||||
import TrainingResultCard from './TrainingResultCard.vue';
|
||||
import { buildMermaidFlowFallbackHtml } from '../../utils/mermaidChart';
|
||||
import type { ChatMessage, InlineDownloadFile, SourceFileLink } from '../../types/chat.types';
|
||||
import type { ShippingInventoryMappingFormPayload, ShippingMatchResultPayload } from '../../types/shipping.types';
|
||||
import type { MaintenanceDevice } from '@/features/maintenance/types/ledger.types';
|
||||
@@ -126,6 +127,33 @@ const isCopied = computed(() => copiedIndex === index);
|
||||
const renderedMarkdown = computed(() => (
|
||||
message.role === 'assistant' ? handlers.renderMarkdown(message.content) : ''
|
||||
));
|
||||
const markdownContainer = ref<HTMLElement | null>(null);
|
||||
|
||||
/**
|
||||
* 用途:将回答中的 Mermaid 流程图代码块转换成内嵌流程卡片。
|
||||
* 依赖:useChatPageMarkdown 为 `mermaid` 代码块保留 `.chat-mermaid` 标记。
|
||||
* 逻辑:不直接执行 Mermaid,避免 Dify 非标准图语法使 Mermaid 在页面根节点注入错误 SVG;
|
||||
* 对可提取的主流程展示节点卡片和箭头,其余图表代码块静默隐藏,不影响普通文本与表格。
|
||||
*/
|
||||
const renderMermaidCharts = async () => {
|
||||
await nextTick();
|
||||
const container = markdownContainer.value;
|
||||
if (!container) return;
|
||||
const nodes = Array.from(container.querySelectorAll<HTMLElement>('pre.chat-mermaid:not([data-mermaid-rendered])'));
|
||||
if (!nodes.length) return;
|
||||
for (const node of nodes) {
|
||||
node.dataset.mermaidRendered = 'pending';
|
||||
const fallbackHtml = buildMermaidFlowFallbackHtml(node.textContent || '');
|
||||
if (fallbackHtml) {
|
||||
node.outerHTML = fallbackHtml;
|
||||
continue;
|
||||
}
|
||||
node.remove();
|
||||
}
|
||||
};
|
||||
|
||||
onMounted(() => { void renderMermaidCharts(); });
|
||||
watch(renderedMarkdown, () => { void renderMermaidCharts(); });
|
||||
const inlineDownloadFiles = computed(() => (
|
||||
message.role === 'assistant' ? handlers.getInlineDownloadFiles(message.content).files : []
|
||||
));
|
||||
@@ -1055,6 +1083,71 @@ function handleInlineDownload(file: InlineDownloadFile): void {
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
:deep(.chat-markdown .chat-mermaid-diagram) {
|
||||
max-width: 100%;
|
||||
overflow: auto;
|
||||
margin: 1rem 0;
|
||||
padding: 1rem;
|
||||
border: 1px solid rgb(219 234 254);
|
||||
border-radius: 0.75rem;
|
||||
background: linear-gradient(135deg, rgb(248 250 252), rgb(239 246 255));
|
||||
}
|
||||
|
||||
:deep(.chat-markdown .chat-mermaid-diagram svg) {
|
||||
display: block;
|
||||
min-width: 36rem;
|
||||
max-width: none;
|
||||
height: auto;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
:deep(.chat-markdown .chat-mermaid-error) {
|
||||
white-space: pre;
|
||||
overflow: auto;
|
||||
color: rgb(127 29 29);
|
||||
}
|
||||
|
||||
:deep(.chat-markdown .chat-mermaid-error-tip) {
|
||||
margin: 0.75rem 0 0.25rem;
|
||||
color: rgb(185 28 28);
|
||||
font-size: 0.8125rem;
|
||||
}
|
||||
|
||||
:deep(.chat-markdown .chat-flow-fallback) {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
max-width: 100%;
|
||||
overflow-x: auto;
|
||||
margin: 1rem 0;
|
||||
padding: 1rem;
|
||||
border: 1px solid rgb(191 219 254);
|
||||
border-radius: 0.75rem;
|
||||
background: linear-gradient(135deg, rgb(248 250 252), rgb(239 246 255));
|
||||
}
|
||||
|
||||
:deep(.chat-markdown .chat-flow-fallback-card) {
|
||||
flex: 0 0 auto;
|
||||
min-width: 8.5rem;
|
||||
max-width: 13rem;
|
||||
padding: 0.75rem 1rem;
|
||||
border: 1px solid rgb(96 165 250);
|
||||
border-radius: 0.625rem;
|
||||
background: white;
|
||||
color: rgb(30 64 175);
|
||||
font-weight: 600;
|
||||
line-height: 1.45;
|
||||
text-align: center;
|
||||
box-shadow: 0 2px 8px rgb(59 130 246 / 0.12);
|
||||
}
|
||||
|
||||
:deep(.chat-markdown .chat-flow-fallback-arrow) {
|
||||
flex: 0 0 auto;
|
||||
color: rgb(37 99 235);
|
||||
font-size: 1.5rem;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
:deep(.chat-markdown .chat-table-scroll) {
|
||||
max-width: 100%;
|
||||
overflow-x: auto;
|
||||
|
||||
Reference in new issue
Block a user