feat(大屏绘制): 战情七页版式 + 对接 selectSqReport 真实数据

- 新增 dashboard-agent 独占战情多页(总览/敌情/我情/战场环境/情况判断/决心建议/处置建议),
  经 DashboardApp 的可选 pages 插槽注入,会商 Step3 大屏多页样式零影响
- 总览由六类数据聚合;六个详情页对接 selectSqReport(防御式解析,容错不抛错,
  接口为空显示「暂无数据」)
- 展示层 desensitizeDeep 脱敏 + 请求加载框;去掉所有「更多」按钮

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
董宏凯andClaude Opus 4.8 committed 2026-06-22 22:47:43 +08:00
1 parent adabfa2fe3
commit fc632f26e9
12 files changed
+2805 -34

No files matched your search

@@ -32,7 +32,17 @@ import { readCopTaskDetail } from "@/core/auth/task-deeplink";
import { desensitizeDeep } from "@/lib/desensitize";
import { useModels } from "@/core/models/hooks";
import { useTheme } from "@/contexts/ThemeContext";
import { DashboardApp } from "@/roundtable-planning/dashboard/DashboardApp";
import { Compass, Crosshair, Shield, Mountain, Lightbulb, Flag, FileText } from "lucide-react";
import { DashboardApp, type DashboardPage } from "@/roundtable-planning/dashboard/DashboardApp";
import { SituationOverview } from "@/roundtable-planning/dashboard-agent/SituationOverview";
import { EnemyDetail } from "@/roundtable-planning/dashboard-agent/EnemyDetail";
import { OurSituation } from "@/roundtable-planning/dashboard-agent/OurSituation";
import { EnvironmentDetail } from "@/roundtable-planning/dashboard-agent/EnvironmentDetail";
import { Judgement } from "@/roundtable-planning/dashboard-agent/Judgement";
import { Decision } from "@/roundtable-planning/dashboard-agent/Decision";
import { Disposal } from "@/roundtable-planning/dashboard-agent/Disposal";
import { parseSqReport, type SqReport } from "@/roundtable-planning/dashboard-agent/sq-report";
import { adaptReportData } from "@/roundtable-planning/dashboard/data-context";
import { DashboardChatPanel } from "@/roundtable-planning/components/DashboardChatPanel";
import { Step2SandboxLayout } from "@/roundtable-planning/components/Step2SandboxLayout";
@@ -59,6 +69,14 @@ function formatNow(): string {
type DashView = "chat" | "page";
type RenderMode = "app" | "html";
/**
* 静态页面阶段开关(先按设计图搭总览版式,动态数据后续再接):
* - 默认落在「大屏页面」视图,直接展示 SituationOverview 静态版式;
* - 不自动调用智能体抽取(避免静态阶段空跑)。
* 接入动态数据后置为 false 即恢复原有「请求数据→智能体抽取→查看大屏」流程。
*/
const STATIC_PREVIEW = true;
/** 从 URL / 路由 state / 登录暂存任务详情解析 taskId。 */
function useTaskId(): string {
const [searchParams] = useSearchParams();
@@ -83,6 +101,8 @@ export default function DashboardAgentPage() {
// 输入 JSON(登录拉取/占位)——auto-start 时由 buildInitialPrompt 闭包读取。
const inputRef = useRef<unknown>(null);
// 战情报告解析结果(selectSqReport → 各页面展示模型);解析失败/无数据 → null(页面回退占位)。
const [sqReport, setSqReport] = useState<SqReport | null>(null);
const dashboard = useStep3Dashboard({
intentReady: null,
@@ -113,7 +133,8 @@ export default function DashboardAgentPage() {
} = dashboard;
const [loading, setLoading] = useState(true);
const [view, setView] = useState<DashView>("chat");
// 静态阶段默认进「大屏页面」,直接展示静态版式(见 STATIC_PREVIEW)。
const [view, setView] = useState<DashView>(STATIC_PREVIEW ? "page" : "chat");
const [renderMode, setRenderMode] = useState<RenderMode>("app");
// 真实接口请求失败/无数据时的提示(真实模式不拿假数据兜底,改为提示+重试)。
const [inputError, setInputError] = useState<string | null>(null);
@@ -152,6 +173,12 @@ export default function DashboardAgentPage() {
fetchDashboardInputJson(taskId).catch(() => null),
]);
inputRef.current = input;
// 解析战情报告 → 各页面展示模型(容错:异常/无数据均不抛错,页面回退占位)。
try {
setSqReport(parseSqReport(input));
} catch {
setSqReport(null);
}
const savedDialogues = (session?.transcript as Step2Dialogue[] | undefined) ?? [];
const validReport = session?.reportJson && parseReportJson(session.reportJson);
if (validReport) {
@@ -161,14 +188,20 @@ export default function DashboardAgentPage() {
} else if (savedDialogues.length > 0) {
// 有历史聊天但无有效结果 → 进生成过程展示历史,不自动重跑(点「重新绘制」可重生成)。
hydrateTranscriptRef.current(savedDialogues, session?.reportJson ?? null);
setView("chat");
// 静态阶段仍停在「大屏页面」看版式(历史对话可点「编辑」查看)。
setView(STATIC_PREVIEW ? "page" : "chat");
} else {
// 无任何记录 → 接口返回了真实数据才启动模型抽取;否则提示(真实模式不拿假数据兜底)。
setView("chat");
if (input) {
startRef.current();
// 静态阶段(STATIC_PREVIEW):不自动抽取,停在「大屏页面」展示静态版式。
if (STATIC_PREVIEW) {
setView("page");
} else {
setInputError("未获取到任务数据:接口请求失败或未返回内容,请稍后重试。");
setView("chat");
if (input) {
startRef.current();
} else {
setInputError("未获取到任务数据:接口请求失败或未返回内容,请稍后重试。");
}
}
}
} finally {
@@ -218,6 +251,30 @@ export default function DashboardAgentPage() {
);
const hasResult = !!dashboardData || !!dashboardHtml;
// 展示层脱敏:所有页面文本经 desensitizeDeep 深度替换后再渲染(与会商大屏一致)。
const safeReport = useMemo<SqReport | null>(() => {
if (!sqReport) return null;
try {
return desensitizeDeep(sqReport) as SqReport;
} catch {
return sqReport; // 脱敏异常不影响展示
}
}, [sqReport]);
// 战情多页:总览 + 六个详情页;详情页传入对应的(脱敏后)真实数据(无则页面回退占位)。
const dashPages: DashboardPage[] = useMemo(
() => [
{ id: "overview", label: "总览", icon: <Compass className="h-4 w-4" />, content: <SituationOverview data={safeReport} /> },
{ id: "enemy", label: "敌情", icon: <Crosshair className="h-4 w-4" />, content: <EnemyDetail data={safeReport?.enemy} /> },
{ id: "ours", label: "我情", icon: <Shield className="h-4 w-4" />, content: <OurSituation data={safeReport?.ours} /> },
{ id: "field", label: "战场环境", icon: <Mountain className="h-4 w-4" />, content: <EnvironmentDetail data={safeReport?.environment} /> },
{ id: "judge", label: "情况判断", icon: <Lightbulb className="h-4 w-4" />, content: <Judgement data={safeReport?.judgement} /> },
{ id: "decision", label: "决心建议", icon: <Flag className="h-4 w-4" />, content: <Decision data={safeReport?.decision} /> },
{ id: "disposal", label: "处置建议", icon: <FileText className="h-4 w-4" />, content: <Disposal data={safeReport?.disposal} /> },
],
[safeReport],
);
// 网页渲染:blob URL 作 iframe src(:target 导航需独立文档 URL,见 Step3DashboardMode 注释)。
const [htmlBlobUrl, setHtmlBlobUrl] = useState<string | null>(null);
useEffect(() => {
@@ -392,13 +449,27 @@ export default function DashboardAgentPage() {
{/* 主体 */}
{loading ? (
// 加载框:请求战情报告期间显示,拿到数据后再渲染大屏(避免先闪占位再跳真实数据)。
<div className="flex flex-1 flex-col items-center justify-center gap-3 text-sm text-slate-500">
<Loader2 className="h-6 w-6 animate-spin text-primary" />
<div className="text-center">
<div className="font-semibold text-slate-700">正在请求任务数据…</div>
<div className="mt-1 text-xs text-slate-400">拉取接口返回后将自动开始智能体抽取绘制</div>
<div className="mt-1 text-xs text-slate-400">拉取接口返回后展示大屏</div>
</div>
</div>
) : view === "page" ? (
renderMode === "html" && htmlBlobUrl ? (
<iframe
title="任务研讨大屏"
src={htmlBlobUrl}
className="min-h-0 w-full flex-1 border-0 bg-white"
sandbox="allow-scripts allow-popups allow-downloads allow-same-origin"
/>
) : (
<div className="min-h-0 flex-1 overflow-auto">
<DashboardApp data={dashboardData} pages={dashPages} />
</div>
)
) : inputError && dialogues.length === 0 ? (
<div className="flex flex-1 items-center justify-center p-8 text-center text-sm text-slate-500">
<div className="max-w-sm">
@@ -414,19 +485,6 @@ export default function DashboardAgentPage() {
</button>
</div>
</div>
) : view === "page" ? (
renderMode === "html" && htmlBlobUrl ? (
<iframe
title="任务研讨大屏"
src={htmlBlobUrl}
className="min-h-0 w-full flex-1 border-0 bg-white"
sandbox="allow-scripts allow-popups allow-downloads allow-same-origin"
/>
) : (
<div className="min-h-0 flex-1 overflow-auto">
<DashboardApp data={dashboardData} />
</div>
)
) : (
<div className="min-h-0 flex-1 p-3">
<section className="h-full min-h-0 overflow-hidden rounded-2xl border border-slate-200/60 bg-white">