移除状态检测功能,专注核心切换功能

- 删除 checkProviderStatus 函数和相关 IPC 处理
- 移除 App.tsx 中所有状态检测相关的状态和函数
- 简化 ProviderList.tsx,去除状态显示和检查按钮
- 清理 types.ts 中的 ProviderStatus 类型定义
- 界面更简洁,专注于供应商切换这一核心功能
This commit is contained in:
farion1231
2025-08-05 23:28:47 +08:00
parent 671f9b34e2
commit ca5035696f
5 changed files with 5 additions and 109 deletions

View File

@@ -1,45 +1,22 @@
import React from 'react'
import { Provider, ProviderStatus } from '../../shared/types'
import { Provider } from '../../shared/types'
import './ProviderList.css'
interface ProviderListProps {
providers: Record<string, Provider>
currentProviderId: string
statuses: Record<string, ProviderStatus>
checkingStatus: Record<string, boolean>
onSwitch: (id: string) => void
onDelete: (id: string) => void
onEdit: (id: string) => void
onCheckStatus: (id: string) => void
}
const ProviderList: React.FC<ProviderListProps> = ({
providers,
currentProviderId,
statuses,
checkingStatus,
onSwitch,
onDelete,
onEdit,
onCheckStatus
onEdit
}) => {
const formatResponseTime = (time: number) => {
if (time < 0) return '-'
return `${time}ms`
}
const getStatusIcon = (status?: ProviderStatus) => {
if (!status) return '⏳'
return status.isOnline ? '✅' : '❌'
}
const getStatusText = (status?: ProviderStatus, isChecking?: boolean) => {
if (isChecking) return '检查中...'
if (!status) return '未检查'
if (status.isOnline) return '正常'
return status.error || '连接失败'
}
return (
<div className="provider-list">
{Object.values(providers).length === 0 ? (
@@ -50,8 +27,6 @@ const ProviderList: React.FC<ProviderListProps> = ({
) : (
<div className="provider-items">
{Object.values(providers).map((provider) => {
const status = statuses[provider.id]
const isChecking = checkingStatus[provider.id]
const isCurrent = provider.id === currentProviderId
return (
@@ -66,7 +41,6 @@ const ProviderList: React.FC<ProviderListProps> = ({
name="provider"
checked={isCurrent}
onChange={() => onSwitch(provider.id)}
disabled={!status?.isOnline}
/>
<span>{provider.name}</span>
{isCurrent && <span className="current-badge">使</span>}
@@ -74,24 +48,7 @@ const ProviderList: React.FC<ProviderListProps> = ({
<div className="provider-url">{provider.apiUrl}</div>
</div>
<div className="provider-status">
<span className="status-icon">{isChecking ? '🔄' : getStatusIcon(status)}</span>
<span className="status-text">{getStatusText(status, isChecking)}</span>
{status?.isOnline && !isChecking && (
<span className="response-time">
{formatResponseTime(status.responseTime)}
</span>
)}
</div>
<div className="provider-actions">
<button
className="check-btn"
onClick={() => onCheckStatus(provider.id)}
disabled={true}
>
{isChecking ? '检查中' : '检查状态'}
</button>
<button
className="enable-btn"
onClick={() => onSwitch(provider.id)}