同步:完善质量分析工作台并更新主题字体

同步已上线的智能分析执行协议、来源查询、图表报告与管理页面配套代码。
补齐数据库迁移、运行依赖和回归测试,保留原有指标计算口径。
统一午夜黑及其他主题的控件细节、中文和业务数字字体。
排除本地业务数据、凭据、预览、发布与验收产物。

验证:生产构建通过,320项前端回归通过;本轮仅同步Git,不再次部署。
This commit is contained in:
2026-10-30 22:40:58 +08:00
parent edef747e3b
commit ff7bbe3e46
393 changed files with 62999 additions and 1783 deletions
+24 -18
View File
@@ -1,12 +1,15 @@
import { Spin } from 'antd';
import { useEffect, useState, type ReactNode } from 'react';
import { CheckCircleOutlined, CloseCircleOutlined, ClockCircleOutlined, RightOutlined } from '@ant-design/icons';
import { analysisIsRunning, compactAnalysisTimeline, duplicatesFinalAnalysisAnswer } from './analysisConversationState';
import { AiMarkdown } from './AiMarkdown';
import { sanitizeAnalysisDisplayText } from './analysisDisplayText';
import { AnalysisThinkingBlock } from './ModelThinkingPanel';
import { orderedAnalysisProcess, groupAdjacentThinking, type ModelThinking } from './analysisModelThinking';
const record = (value: unknown): Record<string, unknown> => value && typeof value === 'object' && !Array.isArray(value) ? value as Record<string, unknown> : {};
const callLabel = (step: Record<string, unknown>) => String(step.label || ({ read: '读取分析资料', mcp_call: '查询质量数据' } as Record<string, string>)[String(step.tool)] || step.tool || '分析步骤');
const INPUT_LABELS: Record<string, string> = { mode: '分析方式', scope: '范围', period: '期间', comparisonPeriod: '对比期间', filters: '筛选', view: '汇总维度', stage: '阶段', dimension: '排名维度', defect: '具体缺陷', category: '缺陷大类', limit: '返回数量', sort: '排序', action: '核查步骤', offset: '明细起点', recordFilter: '明细范围', year: '年', month: '月', quarter: '季度', department: '产业部', group: '业务分组', product: '规格', projectGroup: '项目组', includeUnassigned: '包含未分类行' };
const INPUT_LABELS: Record<string, string> = { mode: '分析方式', scope: '范围', period: '期间', comparisonPeriod: '对比期间', filters: '筛选', view: '汇总维度', stage: '阶段', dimension: '排名维度', defect: '具体缺陷', category: '缺陷大类', limit: '返回数量', sort: '排序', action: '核查步骤', offset: '明细起点', recordFilter: '明细范围', year: '年', month: '月', quarter: '季度', monthStart: '起始月份', monthEnd: '结束月份', department: '产业部', group: '业务分组', product: '规格', projectGroup: '项目组', includeUnassigned: '包含未分类行' };
const INPUT_VALUES: Record<string, string> = { overall: '全公司', auto_combined: '汽车交通合计', auto_domestic: '汽车交通国内', auto_overseas: '汽车交通海外', black: '黑片', bright: '亮片', category: '缺陷大类', defect: '具体缺陷', product: '规格', department: '产业部', group: '业务分组', projectGroup: '项目组', scrap_delta: '报废增量', current_scrap: '当前报废重量', rate_drop: '合格率降幅', catalog: '确认可用数据', query: '指标查询', compare: '期间比较', top: '重点对象排名', changes: '变化对象追查', defects: '具体缺陷分析', details: '来源明细核查', investigate: '全量来源调查', source: '原表核验', rows: '分页明细', fields: '字段字典', overview: '完整范围统计', differences: '全部差额行', unexpectedDifferences: '扣除预期口径后的差额行' };
function inputText(input: Record<string, unknown>): string {
return Object.entries(input).map(([key, value]) => {
@@ -36,7 +39,7 @@ function ToolCall({ entry, running }: { entry: Record<string, unknown>; running:
</details>;
}
export function AnalysisProcess({ turn }: { turn: Record<string, unknown> }) {
export function AnalysisProcess({ turn, metadata }: { turn: Record<string, unknown>; metadata?: ReactNode }) {
const result = record(turn.result);
const plan = record(turn.plan || result.plan);
const running = analysisIsRunning(turn.status || result.status);
@@ -45,20 +48,23 @@ export function AnalysisProcess({ turn }: { turn: Record<string, unknown> }) {
const answer = String(result.answer || turn.answer || '');
const rawSteps = turn.steps || result.steps || plan.steps;
const steps = Array.isArray(rawSteps) ? rawSteps.map(record) : [];
if (timeline.length) return <section className="analysis-event-stream" aria-label="实时分析对话">
{timeline.map((entry, index) => {
const text = sanitizeAnalysisDisplayText(String(entry.text || ''));
if (entry.kind === 'assistant' && !text.trim()) return null;
// The full final answer is rendered immediately after this stream. Avoid a duplicate.
if (!running && index === timeline.length - 1 && entry.kind === 'assistant' && duplicatesFinalAnalysisAnswer(String(entry.text || ''), answer)) return null;
if (entry.kind === 'assistant') return <div className="analysis-answer analysis-event-note" key={String(entry.sequence)}><AiMarkdown content={text} className="ai-answer" /></div>;
const step = steps.find(item => item.toolCallId && item.toolCallId === entry.toolCallId);
return <ToolCall key={String(entry.sequence)} entry={{ ...entry, ...(step?.recovered ? { recovered: true, text: step.outputSummary || '调整调用后已重试成功' } : {}) }} running={running} />;
})}
</section>;
if (!steps.length) return running ? <p className="analysis-chat-notice" role="status">{sanitizeAnalysisDisplayText(String(turn.progressMessage || plan.progressMessage || '正在准备分析…'))}</p> : null;
return <section className="analysis-event-stream" aria-label="已保存的分析调用">
<p className="analysis-chat-notice">此历史记录仅保存了工具摘要,未记录交错对话事件。</p>
{steps.map((step, index) => <ToolCall key={index} entry={step} running={running} />)}
</section>;
const fallback = steps.map((step, index) => ({ ...step, kind: 'tool', sequence: index, at: step.startedAt, hasResult: ['completed', 'failed'].includes(String(step.status)) }));
const events = groupAdjacentThinking(orderedAnalysisProcess(turn, timeline.length ? timeline : fallback));
const [open, setOpen] = useState(running);
useEffect(() => { setOpen(running); }, [running, turn.id]);
const content = events.map(entry => {
if (entry.kind === 'thinking') return <AnalysisThinkingBlock key={String(entry.key)} entry={entry as unknown as ModelThinking} running={running} />;
const text = sanitizeAnalysisDisplayText(String(entry.text || ''));
if (entry.kind === 'assistant') {
if (!text.trim() || !running && entry.sequence === timeline.at(-1)?.sequence && timeline.at(-1)?.kind === 'assistant' && duplicatesFinalAnalysisAnswer(text, answer)) return null;
return <div className="analysis-answer analysis-event-note" key={String(entry.key)}><AiMarkdown content={text} className="ai-answer" /></div>;
}
const step = steps.find(item => item.toolCallId && item.toolCallId === entry.toolCallId);
return <ToolCall key={String(entry.key)} entry={{ ...entry, ...(step?.recovered ? { recovered: true, text: step.outputSummary || '调整调用后已重试成功' } : {}) }} running={running} />;
});
if (!events.length) return <>{metadata}{running && <p className="analysis-chat-notice" role="status">{sanitizeAnalysisDisplayText(String(turn.progressMessage || plan.progressMessage || '正在准备分析…'))}</p>}</>;
return <details className="analysis-process-history analysis-agent-process" open={open} onToggle={event => setOpen(event.currentTarget.open)}>
<summary aria-label={running ? '分析运行信息,展开分析过程' : '分析运行信息,展开已保存过程'}>{metadata || <span>{running ? '分析中' : '已完成'}</span>}<RightOutlined aria-hidden="true" /></summary>
<div className="analysis-agent-stream" aria-label={running ? '实时分析对话' : '已保存的分析过程'}>{content}</div>
</details>;
}