diff --git a/frontend/src/components/personal-report/personal-report-page.tsx b/frontend/src/components/personal-report/personal-report-page.tsx index fcb64d2e..9d9e9358 100644 --- a/frontend/src/components/personal-report/personal-report-page.tsx +++ b/frontend/src/components/personal-report/personal-report-page.tsx @@ -169,7 +169,7 @@ export function PersonalReportPage({ reportId }: { reportId: string }) {

{generating && (

- 生成完成后页面会自动显示。生成期间打印按钮保持禁用。 + 生成完成后页面会自动显示。

)} @@ -242,11 +242,7 @@ export function PersonalReportPage({ reportId }: { reportId: string }) { const document = state.document; return (
- +
diff --git a/frontend/src/components/personal-report/report-actions.tsx b/frontend/src/components/personal-report/report-actions.tsx index 1ca7fd89..6617d5e4 100644 --- a/frontend/src/components/personal-report/report-actions.tsx +++ b/frontend/src/components/personal-report/report-actions.tsx @@ -1,66 +1,16 @@ -/** - * Header action bar for the personal report page. - * - * The print button stays disabled until the report document is ready; printing - * goes through client-report-export (window.print only, no server PDF). - * Environments that cannot print reliably (WeChat in-app browser) get a - * friendly hint instead of a broken printout. - */ - -"use client"; - -import { useState } from "react"; +/** Header action bar for the personal report page. */ import Link from "next/link"; -import { Printer, ArrowLeft, TriangleAlert } from "lucide-react"; - -import { - detectPrintRestriction, - isPrintSupported, - printPersonalReport, - safeReportFilename, -} from "@/lib/client-report-export"; -import { Button } from "@/components/ui/button"; - -interface ReportActionsProps { - reportId: string; - ready: boolean; - reportTitle?: string; -} - -export function ReportActions({ reportId, ready, reportTitle }: ReportActionsProps) { - const [busy, setBusy] = useState(false); - const [notice, setNotice] = useState(null); - const restriction = detectPrintRestriction(); - - const disabled = !ready || busy || !isPrintSupported(); - - async function handlePrint() { - if (disabled) { - return; - } - if (restriction.restricted) { - setNotice(restriction.message ?? null); - return; - } - setBusy(true); - setNotice(null); - try { - await printPersonalReport({ - title: reportTitle?.trim() || safeReportFilename(reportId), - }); - } finally { - setBusy(false); - } - } +import { ArrowLeft } from "lucide-react"; +export function ReportActions() { return ( ); } diff --git a/frontend/tests/personal-report-view.test.ts b/frontend/tests/personal-report-view.test.ts index a6cbd95d..feddd49a 100644 --- a/frontend/tests/personal-report-view.test.ts +++ b/frontend/tests/personal-report-view.test.ts @@ -227,13 +227,13 @@ test("canonical contract rejects malformed documents", () => { assert.equal(safeParseReportDocument(badRefs).ok, false, "dangling evidenceRefs must fail guards"); }); -test("print button is gated on ready state (source contract)", () => { +test("PDF action is hidden while the export format is unavailable", () => { const actionsSource = readFileSync( new URL("../src/components/personal-report/report-actions.tsx", import.meta.url), "utf8", ); - assert.match(actionsSource, /const disabled = !ready \|\| busy \|\| !isPrintSupported\(\)/); - assert.match(actionsSource, /disabled=\{disabled\}/); - assert.match(actionsSource, /printPersonalReport/); - assert.match(actionsSource, /personal-report-screen-only/); + assert.match(actionsSource, /返回对话/); + assert.doesNotMatch(actionsSource, /打印 \/ 保存为 PDF/); + assert.doesNotMatch(actionsSource, /printPersonalReport/); + assert.doesNotMatch(actionsSource, /Printer/); });