import { useRef, useState } from 'react'; import type { ProblemFramingPlan } from '../../../shared/types/api'; import { useI18n } from '../../../shared/i18n'; import { ProblemPlanEditor } from './ProblemPlanEditor'; interface ProblemFramingOverlayProps { open: boolean; status: 'loading' | 'ready' | 'error'; plan: ProblemFramingPlan | null; error: string | null; adjustment: string; generating: boolean; onAdjustmentChange: (value: string) => void; onRetry: () => void; onInitialRetry: () => void; onPlanChange: (plan: ProblemFramingPlan) => void; onGenerate: () => void; onClose: () => void; } /** 等待时卡片右上角的三只猫爪:猫在整理结构。方案就绪后隐去,不抢位。*/ function PawStamp({ delay = 0 }: { delay?: number }) { return (
); } function WaitingPaws() { return ( ); } /** 错误只是一个通知:小卡片、全文可见、可复制。不拿整屏挡住用户。 */ function ProblemErrorCard({ error, onRetry, onClose }: { error: string | null; onRetry: () => void; onClose: () => void; }) { const { t } = useI18n(); const [copied, setCopied] = useState(false); const detail = error || t('problem.initialErrorDescription'); const detailRef = useRef(null); const copy = async () => { try { await navigator.clipboard.writeText(detail); } catch { // 没有剪贴板权限时退回手动选中,至少不挡路。 const node = detailRef.current; if (node) { const range = document.createRange(); range.selectNodeContents(node); const selection = window.getSelection(); selection?.removeAllRanges(); selection?.addRange(range); } } setCopied(true); window.setTimeout(() => setCopied(false), 1600); }; return
{/* 和 AiModifyModal 一套语汇:沉浸遮罩 + 宽圆角纸面。 */}

{t('problem.initialErrorTitle')}

{detail}
; } export function ProblemFramingOverlay(props: ProblemFramingOverlayProps) { return props.open ? : null; } function ProblemFramingOverlayContent({ status, plan, error, adjustment, generating, onAdjustmentChange, onRetry, onInitialRetry, onPlanChange, onGenerate, onClose, }: ProblemFramingOverlayProps) { const { t } = useI18n(); const [confirmDiscard, setConfirmDiscard] = useState(false); const busy = status === 'loading' || generating; const statusKey = status === 'loading' ? plan ? 'problem.status.refining' : 'problem.status.loading' : status === 'ready' ? 'problem.status.ready' : 'problem.status.error'; // 失败且手里还没有任何规划卡:只是一个错误通知,不该占满一屏。 if (status === 'error' && !plan) { return ; } return
{status === 'loading' && }

{t(statusKey)}

{plan ? : status === 'loading' ?