LintModal.tsx
3.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
"use client";
import type { RefObject } from "react";
import { ShieldCheck, CheckCircle2, X } from "lucide-react";
import { MessageBubble, type ReasoningStep } from "@/components/MessageBubble";
/** Lint 对话消息:与父级 lintHistory 的元素结构一致。 */
export interface LintMessage {
role: "user" | "ai";
content: string;
reasoning?: ReasoningStep[];
startTime?: number;
endTime?: number;
}
/**
* Wiki 健康检查(Lint)弹窗(纯展示)。
*
* 扫描过程由父级的 handleLint 驱动并流式写入 lintHistory,
* 这里只渲染对话与扫描状态;末尾 ref 交给父级做自动滚底。
*/
export interface LintModalProps {
open: boolean;
onClose: () => void;
/** 扫描中:末条消息显示流式态,标题区显示脉冲提示 */
isLinting: boolean;
lintHistory: LintMessage[];
/** 列表末尾锚点,父级据此滚动到底部 */
lintEndRef: RefObject<HTMLDivElement | null>;
}
export const LintModal = ({ open, onClose, isLinting, lintHistory, lintEndRef }: LintModalProps) => {
if (!open) return null;
return (
<div className="fixed inset-0 z-50 flex items-center justify-center bg-slate-900/40 backdrop-blur-sm p-8 animate-in fade-in duration-200">
<div className="bg-slate-50 w-full max-w-4xl h-[80vh] rounded-3xl shadow-2xl flex flex-col overflow-hidden border border-slate-200/50">
<div className="h-16 px-6 bg-white border-b border-slate-100 flex items-center justify-between shrink-0">
<div className="flex items-center gap-3">
<div className="w-10 h-10 bg-emerald-100 rounded-xl flex items-center justify-center">
<ShieldCheck className="w-5 h-5 text-emerald-600" />
</div>
<div>
<h3 className="font-bold text-sm text-slate-800">Wiki 健康检查 (Lint)</h3>
<div className="flex items-center gap-1.5">
{isLinting ? (
<>
<div className="w-1.5 h-1.5 bg-emerald-400 rounded-full animate-pulse" />
<span className="text-[10px] text-slate-500 font-medium tracking-wider">正在扫描知识库...</span>
</>
) : (
<>
<CheckCircle2 className="w-3 h-3 text-emerald-500" />
<span className="text-[10px] text-slate-500 font-medium tracking-wider">扫描完成</span>
</>
)}
</div>
</div>
</div>
<button
onClick={onClose}
className="p-2 hover:bg-slate-100 rounded-lg transition-colors text-slate-400 hover:text-slate-800"
>
<X className="w-5 h-5" />
</button>
</div>
<div className="flex-1 overflow-y-auto p-6 scrollbar-thin bg-white/50 flex flex-col">
{lintHistory.map((msg, idx) => (
<MessageBubble
key={idx}
role={msg.role}
content={msg.content}
reasoning={msg.reasoning}
isStreaming={isLinting && idx === lintHistory.length - 1}
startTime={msg.startTime}
endTime={msg.endTime}
/>
))}
<div ref={lintEndRef} />
</div>
</div>
</div>
);
};
export default LintModal;