feat:修复BUG
This commit is contained in:
@@ -55,6 +55,7 @@ export default function ProvidersPage() {
|
||||
latency_ms?: number
|
||||
message?: string
|
||||
} | null>(null)
|
||||
const [testingId, setTestingId] = useState<number | null>(null)
|
||||
|
||||
const [form, setForm] = useState({
|
||||
name: '',
|
||||
@@ -234,6 +235,7 @@ export default function ProvidersPage() {
|
||||
|
||||
const testProvider = async (provider: Provider) => {
|
||||
setTestResult(null)
|
||||
setTestingId(provider.id)
|
||||
setError('')
|
||||
|
||||
try {
|
||||
@@ -249,6 +251,8 @@ export default function ProvidersPage() {
|
||||
return
|
||||
}
|
||||
setTestResult({ ok: false, message: err?.message || '测试失败' })
|
||||
} finally {
|
||||
setTestingId(null)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -278,6 +282,24 @@ export default function ProvidersPage() {
|
||||
</div>
|
||||
)}
|
||||
|
||||
{testResult && (
|
||||
<div
|
||||
className={
|
||||
testResult.ok
|
||||
? 'rounded-md border border-emerald-500/30 bg-emerald-500/10 px-3 py-2 text-sm text-emerald-700 dark:text-emerald-300'
|
||||
: 'rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm text-destructive'
|
||||
}
|
||||
>
|
||||
{testResult.ok ? (
|
||||
<div>
|
||||
测试成功{typeof testResult.latency_ms === 'number' ? `(延迟 ${testResult.latency_ms}ms)` : ''}
|
||||
</div>
|
||||
) : (
|
||||
<div>{testResult.message || '测试失败'}</div>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div className="flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between">
|
||||
<div className="flex-1">
|
||||
<Input
|
||||
@@ -379,8 +401,8 @@ export default function ProvidersPage() {
|
||||
<Pencil className="mr-2 h-4 w-4" />
|
||||
编辑
|
||||
</Button>
|
||||
<Button size="sm" variant="outline" onClick={() => testProvider(p)}>
|
||||
测试
|
||||
<Button size="sm" variant="outline" onClick={() => testProvider(p)} disabled={testingId === p.id}>
|
||||
{testingId === p.id ? '测试中...' : '测试'}
|
||||
</Button>
|
||||
<Button size="sm" variant="destructive" onClick={() => handleDelete(p)}>
|
||||
<Trash2 className="mr-2 h-4 w-4" />
|
||||
|
||||
Reference in New Issue
Block a user