Files
archived-gitea-ai-assistant/frontend/src/components/llm/TestResultDialog.tsx
jeffusion c45cb34a35 feat(ui): add LLM provider management frontend
Add complete Web UI for LLM provider configuration: provider list with
enable/disable toggles, add/edit dialog, connection testing with result
display, role assignment cards, and model combobox with API/recommended/custom
tags. All labels in Chinese. Add description prop to SelectItem for
Radix Select rendering fix. Register route and nav link.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode)
2026-03-24 12:30:13 +08:00

90 lines
3.8 KiB
TypeScript

import { Button } from '@/components/ui/button';
import type { TestResult } from '@/services/llmProviderService';
import { CheckCircle2, XCircle } from 'lucide-react';
interface TestResultDialogProps {
open: boolean;
onOpenChange: (open: boolean) => void;
result: TestResult | null;
providerName: string;
}
export function TestResultDialog({ open, onOpenChange, result, providerName }: TestResultDialogProps) {
if (!open || !result) return null;
return (
<div className="fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm">
<div className="glass-panel w-full max-w-md bg-zinc-950 border border-white/10 rounded-xl shadow-2xl overflow-hidden flex flex-col max-h-[90vh]">
<div className="px-6 py-4 border-b border-white/10">
<h2 className="text-xl font-bold text-zinc-100"> - {providerName}</h2>
</div>
<div className="p-6 flex-1 overflow-y-auto space-y-5">
{result.success ? (
<div className="space-y-4">
<div className="flex items-center gap-3 text-green-500">
<CheckCircle2 className="w-8 h-8" />
<span className="text-lg font-medium"></span>
</div>
<div className="space-y-2 text-sm text-zinc-300">
{result.latencyMs !== undefined && (
<div className="flex justify-between border-b border-white/5 pb-2">
<span className="text-zinc-500">:</span>
<span>{result.latencyMs} ms</span>
</div>
)}
{result.model && (
<div className="flex justify-between border-b border-white/5 pb-2">
<span className="text-zinc-500">:</span>
<span className="font-mono">{result.model}</span>
</div>
)}
{result.message && (
<div className="space-y-2 pt-2">
<span className="text-zinc-500">AI :</span>
<div className="bg-zinc-900 border border-white/10 rounded-md p-3 max-h-48 overflow-y-auto whitespace-pre-wrap font-mono text-xs">
{result.message}
</div>
</div>
)}
</div>
</div>
) : (
<div className="space-y-4">
<div className="flex items-center gap-3 text-red-500">
<XCircle className="w-8 h-8" />
<span className="text-lg font-medium"></span>
</div>
<div className="space-y-2 text-sm text-zinc-300">
{result.latencyMs !== undefined && (
<div className="flex justify-between border-b border-white/5 pb-2">
<span className="text-zinc-500">:</span>
<span>{result.latencyMs} ms</span>
</div>
)}
<div className="space-y-2 pt-2">
<span className="text-zinc-500">:</span>
<div className="bg-zinc-900/50 border border-red-500/20 text-red-400 rounded-md p-3 max-h-48 overflow-y-auto whitespace-pre-wrap font-mono text-xs">
{result.error || result.message || '未知错误'}
</div>
</div>
</div>
</div>
)}
</div>
<div className="px-6 py-4 border-t border-white/10 flex justify-end bg-zinc-900/50">
<Button type="button" onClick={() => onOpenChange(false)} className="bg-primary text-primary-foreground hover:bg-primary/90">
</Button>
</div>
</div>
</div>
);
}