统一:DSH 智能分析、Top100 与图表静默恢复

接入 DSH 专用运行时和对话界面,保留模型原始回答,支持会话分页、连续追问与显式报告。
补齐组合筛选、各维度 Top100、分组查询到排名图的转换,图表故障静默省略并基于保存数据自动恢复。
优化报告风格、图表顺序和表格换行,更新接入说明及构建输入。

验证:独立目录前后端构建通过;118 项 Java、102 项前端、102 项图表、14 项 DSH 应用和 13 项组合筛选检查通过。
仅提交相关源码、锁定依赖与测试;不包含凭据、会话、业务数据或本地产物。
This commit is contained in:
2026-11-12 11:57:41 +08:00
parent cc8832c8e5
commit f1a2fbd494
166 changed files with 26281 additions and 2248 deletions
+27 -5
View File
@@ -29,10 +29,15 @@ function isTableStart(lines: string[], index: number): boolean {
return separators.length > 0 && separators.every(cell => /^:?-{3,}:?$/.test(cell));
}
function isRule(line: string): boolean {
return /^\s{0,3}(?:(?:-\s*){3,}|(?:\*\s*){3,}|(?:_\s*){3,})$/.test(line);
}
function isBlockStart(lines: string[], index: number): boolean {
const line = lines[index];
return /^\s*#{1,6}\s+/.test(line)
|| /^\s*```/.test(line)
|| isRule(line) || /^\s{0,3}>/.test(line)
|| /^\s*(?:[-*+]\s+|\d+[.)]\s+)/.test(line)
|| isTableStart(lines, index);
}
@@ -57,9 +62,9 @@ function readingSentences(value: string, boundaries = '。!?;'): string[]
}
/** Renders the small Markdown subset used by analysis answers with React text nodes only. */
export function AiMarkdown({ content, className, evidenceLabels, evidencePrefix, layout }: { content: string; className?: string; evidenceLabels?: Record<string, string>; evidencePrefix?: string; layout?: 'conclusions' | 'sections' }) {
export function AiMarkdown({ content, className, evidenceLabels, evidencePrefix, layout, preserveSource = false }: { content: string; className?: string; evidenceLabels?: Record<string, string>; evidencePrefix?: string; layout?: 'conclusions' | 'sections'; preserveSource?: boolean }) {
const inline = (value: string, key: string) => inlineMarkdown(value, key, evidenceLabels, evidencePrefix);
const lines = sanitizeAnalysisDisplayText(content).replaceAll('\r\n', '\n').replaceAll('\r', '\n').split('\n');
const lines = (preserveSource ? content : sanitizeAnalysisDisplayText(content)).replaceAll('\r\n', '\n').replaceAll('\r', '\n').split('\n');
const blocks: ReactNode[] = [];
let index = 0;
let leadPending = layout === 'conclusions';
@@ -100,6 +105,22 @@ export function AiMarkdown({ content, className, evidenceLabels, evidencePrefix,
const line = lines[index];
if (!line.trim()) { index += 1; continue; }
if (isRule(line)) {
blocks.push(<hr key={`rule-${blocks.length}`} />);
index += 1;
continue;
}
if (/^\s{0,3}>/.test(line)) {
const quote: string[] = [];
while (index < lines.length && /^\s{0,3}>/.test(lines[index])) quote.push(lines[index++].replace(/^\s{0,3}> ?/, ''));
blocks.push(<blockquote key={`quote-${blocks.length}`}>{quote.flatMap((part, partIndex) => [
...(partIndex ? [<br key={`break-${partIndex}`} />] : []),
...inline(part, `quote-${blocks.length}-${partIndex}`),
])}</blockquote>);
continue;
}
const fence = line.match(/^\s*```([^`]*)$/);
if (fence) {
leadPending = false;
@@ -129,14 +150,15 @@ export function AiMarkdown({ content, className, evidenceLabels, evidencePrefix,
if (isTableStart(lines, index)) {
leadPending = false;
const headers = tableCells(lines[index]);
const hasIndex = ['序号', '排名', '名次'].includes(headers[0]?.replace(/[*`]/g, '').trim() || '');
const existingIndex = ['序号', '排名', '名次'].includes(headers[0]?.replace(/[*`]/g, '').trim() || '');
const hasIndex = preserveSource || existingIndex;
index += 2;
const body: string[][] = [];
while (index < lines.length && lines[index].trim() && lines[index].includes('|')) body.push(tableCells(lines[index++]));
const alignments = headers.map((header, column) => tableTextAlignment(header, body.map(row => row[column])));
blocks.push(<div className="ai-markdown-table-wrap" key={`table-${blocks.length}`}><table>
<thead><tr>{!hasIndex && <th className="ai-markdown-index">序号</th>}{headers.map((cell, cellIndex) => <th key={cellIndex} style={{ textAlign: alignments[cellIndex] === 'left' ? 'left' : undefined }} className={hasIndex && cellIndex === 0 ? 'ai-markdown-index' : undefined}>{inline(cell, `th-${cellIndex}`)}</th>)}</tr></thead>
<tbody>{body.map((row, rowIndex) => <tr key={rowIndex}>{!hasIndex && <td className="ai-markdown-index">{rowIndex + 1}</td>}{headers.map((_, cellIndex) => <td key={cellIndex} style={{ textAlign: alignments[cellIndex] === 'left' ? 'left' : undefined }} className={hasIndex && cellIndex === 0 ? 'ai-markdown-index' : undefined}>{inline(row[cellIndex] || '', `td-${rowIndex}-${cellIndex}`)}</td>)}</tr>)}</tbody>
<thead><tr>{!hasIndex && <th className="ai-markdown-index">序号</th>}{headers.map((cell, cellIndex) => <th key={cellIndex} style={{ textAlign: alignments[cellIndex] === 'left' ? 'left' : undefined }} className={existingIndex && cellIndex === 0 ? 'ai-markdown-index' : undefined}>{inline(cell, `th-${cellIndex}`)}</th>)}</tr></thead>
<tbody>{body.map((row, rowIndex) => <tr key={rowIndex}>{!hasIndex && <td className="ai-markdown-index">{rowIndex + 1}</td>}{headers.map((_, cellIndex) => <td key={cellIndex} style={{ textAlign: alignments[cellIndex] === 'left' ? 'left' : undefined }} className={[existingIndex && cellIndex === 0 && 'ai-markdown-index', alignments[cellIndex] === 'left' && 'ai-markdown-prose'].filter(Boolean).join(' ') || undefined}>{inline(row[cellIndex] || '', `td-${rowIndex}-${cellIndex}`)}</td>)}</tr>)}</tbody>
</table></div>);
if (tableNote) { blocks.push(note(tableNote)); tableNote = ''; }
continue;