31 lines
1.0 KiB
TypeScript
31 lines
1.0 KiB
TypeScript
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>
|
||
)
|
||
}
|