Commit c0d27880 by luoqi

fix(web): 全屏按钮挪到 JSON 原文块(RawJson)而非整个证据链面板

上一版加错位置。改到 RawJson 控制行右侧:全屏时 JSON 块 fixed inset-0 覆盖全屏、<pre> 去 max-h-80 改 flex-1 overflow-auto 撑满可滚,Esc 退出。便于看全大段原始报文 JSON。

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
parent 225756d5
...@@ -240,36 +240,12 @@ function WhyRecalled({ data }: { data: RecallDebugReport }) { ...@@ -240,36 +240,12 @@ function WhyRecalled({ data }: { data: RecallDebugReport }) {
}, [plans]); }, [plans]);
const selected = plans.find((p) => p.planId === selectedId) ?? plans[0] ?? null; const selected = plans.find((p) => p.planId === selectedId) ?? plans[0] ?? null;
// 证据链面板可全屏(CSS 固定覆盖,Esc 退出)
const [fullscreen, setFullscreen] = useState(false);
useEffect(() => {
if (!fullscreen) return;
const onKey = (e: KeyboardEvent) => {
if (e.key === 'Escape') setFullscreen(false);
};
window.addEventListener('keydown', onKey);
return () => window.removeEventListener('keydown', onKey);
}, [fullscreen]);
return ( return (
<Card <Card>
className={ <CardHeader>
fullscreen ? 'fixed inset-0 z-50 m-0 flex flex-col overflow-hidden rounded-none' : undefined
}
>
<CardHeader className="flex flex-row items-center justify-between space-y-0">
<CardTitle className="text-base">为什么召 · 证据链(T0)</CardTitle> <CardTitle className="text-base">为什么召 · 证据链(T0)</CardTitle>
<button
type="button"
onClick={() => setFullscreen((v) => !v)}
title={fullscreen ? '退出全屏 (Esc)' : '全屏'}
aria-label={fullscreen ? '退出全屏' : '全屏'}
className="rounded p-1 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground"
>
{fullscreen ? <Minimize2 className="h-4 w-4" /> : <Maximize2 className="h-4 w-4" />}
</button>
</CardHeader> </CardHeader>
<CardContent className={fullscreen ? 'flex-1 space-y-4 overflow-auto' : 'space-y-4'}> <CardContent className="space-y-4">
{!hasActivePlan && ( {!hasActivePlan && (
<p className="text-sm text-muted-foreground"> <p className="text-sm text-muted-foreground">
无 active plan。 无 active plan。
...@@ -450,9 +426,23 @@ function deepParseJson(value: unknown): unknown { ...@@ -450,9 +426,23 @@ function deepParseJson(value: unknown): unknown {
function RawJson({ value }: { value: unknown }) { function RawJson({ value }: { value: unknown }) {
const [expanded, setExpanded] = useState(true); const [expanded, setExpanded] = useState(true);
// JSON 数据量大 → 可全屏看全(CSS 固定覆盖,Esc 退出)
const [fullscreen, setFullscreen] = useState(false);
const text = JSON.stringify(deepParseJson(value), null, 2); const text = JSON.stringify(deepParseJson(value), null, 2);
useEffect(() => {
if (!fullscreen) return;
const onKey = (e: KeyboardEvent) => {
if (e.key === 'Escape') setFullscreen(false);
};
window.addEventListener('keydown', onKey);
return () => window.removeEventListener('keydown', onKey);
}, [fullscreen]);
return ( return (
<div className="rounded bg-muted/60"> <div
className={`rounded bg-muted/60 ${
fullscreen ? 'fixed inset-0 z-50 m-0 flex flex-col rounded-none' : ''
}`}
>
<div className="flex items-center gap-2 px-2 pt-1.5"> <div className="flex items-center gap-2 px-2 pt-1.5">
<button <button
type="button" type="button"
...@@ -468,8 +458,21 @@ function RawJson({ value }: { value: unknown }) { ...@@ -468,8 +458,21 @@ function RawJson({ value }: { value: unknown }) {
> >
复制 复制
</button> </button>
<button
type="button"
onClick={() => setFullscreen((v) => !v)}
title={fullscreen ? '退出全屏 (Esc)' : '全屏看全'}
aria-label={fullscreen ? '退出全屏' : '全屏'}
className="ml-auto rounded p-0.5 text-muted-foreground hover:bg-muted hover:text-foreground"
>
{fullscreen ? <Minimize2 className="h-3.5 w-3.5" /> : <Maximize2 className="h-3.5 w-3.5" />}
</button>
</div> </div>
<pre className="max-h-80 overflow-auto whitespace-pre-wrap break-words p-2 font-mono text-[11px] leading-relaxed text-foreground/80"> <pre
className={`whitespace-pre-wrap break-words p-2 font-mono text-[11px] leading-relaxed text-foreground/80 ${
fullscreen ? 'flex-1 overflow-auto' : 'max-h-80 overflow-auto'
}`}
>
{expanded ? text : JSON.stringify(value, null, 2)} {expanded ? text : JSON.stringify(value, null, 2)}
</pre> </pre>
</div> </div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment