Files
ai-ticket-platform/frontend/src/components/app/AppReferenceCard.tsx
2026-07-14 13:39:36 +08:00

31 lines
1.0 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { Badge } from '@/components/ui/badge'
const sourceLabels: Record<string, string> = {
knowledge_item: '知识条目',
solution: '解决方案',
ticket: '历史工单',
document: '文档'
}
type AppReferenceCardProps = {
title: string
sourceType: string
content: string
score: number
sourceLabel?: string
}
export function AppReferenceCard({ title, sourceType, content, score, sourceLabel }: AppReferenceCardProps) {
return (
<article className="grid gap-2 rounded-md border border-border bg-background p-3">
<div className="flex flex-wrap items-center gap-2">
<p className="font-medium text-foreground">{title}</p>
<Badge variant="secondary">{sourceLabels[sourceType] ?? sourceType}</Badge>
<Badge variant="outline">匹配度 {Math.round(score * 100)}%</Badge>
</div>
<p className="line-clamp-4 whitespace-pre-line text-sm leading-6 text-muted-foreground">{content}</p>
{sourceLabel ? <p className="text-xs text-muted-foreground">来源:{sourceLabel}</p> : null}
</article>
)
}