diff --git a/src/components/RelayStationManager.tsx b/src/components/RelayStationManager.tsx index f38fcc6..871793e 100644 --- a/src/components/RelayStationManager.tsx +++ b/src/components/RelayStationManager.tsx @@ -9,22 +9,22 @@ import { Textarea } from '@/components/ui/textarea'; import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select'; import { Switch } from '@/components/ui/switch'; import { useTranslation } from '@/hooks/useTranslation'; -import { - RelayStation, - CreateRelayStationRequest, - UpdateRelayStationRequest, - RelayStationAdapter, +import { + RelayStation, + CreateRelayStationRequest, + UpdateRelayStationRequest, + RelayStationAdapter, AuthMethod, ConnectionTestResult, - api + api } from '@/lib/api'; -import { - Plus, - Edit, - Trash2, - Globe, - CheckCircle, - XCircle, +import { + Plus, + Edit, + Trash2, + Globe, + CheckCircle, + XCircle, Wifi, WifiOff, Server, @@ -48,7 +48,7 @@ const RelayStationManager: React.FC = ({ onBack }) => const [togglingEnable, setTogglingEnable] = useState>({}); const [currentConfig, setCurrentConfig] = useState>({}); const [loadingConfig, setLoadingConfig] = useState(false); - + const { t } = useTranslation(); // 加载中转站列表 @@ -96,7 +96,7 @@ const RelayStationManager: React.FC = ({ onBack }) => setTestingConnections(prev => ({ ...prev, [stationId]: true })); const result = await api.relayStationTestConnection(stationId); setConnectionTests(prev => ({ ...prev, [stationId]: result })); - + if (result.success) { alert(t('relayStation.connectionSuccess')); } else { @@ -113,7 +113,7 @@ const RelayStationManager: React.FC = ({ onBack }) => // 删除中转站 const deleteStation = async (stationId: string) => { if (!confirm(t('relayStation.deleteConfirm'))) return; - + try { await api.relayStationDelete(stationId); alert(t('relayStation.deleteSuccess')); @@ -156,7 +156,7 @@ const RelayStationManager: React.FC = ({ onBack }) => const getStatusBadge = (station: RelayStation) => { const enabled = station.enabled; const isToggling = togglingEnable[station.id]; - + return (
= ({ onBack }) => - { setShowCreateDialog(false); loadStations(); @@ -302,7 +302,7 @@ const RelayStationManager: React.FC = ({ onBack }) => {station.api_url}
- + {station.description && (

{station.description} @@ -341,7 +341,7 @@ const RelayStationManager: React.FC = ({ onBack }) => )} {t('relayStation.testConnection')} - +

- +
+ onValueChange={(value: AuthMethod) => setFormData(prev => ({ ...prev, auth_method: value })) } > @@ -550,7 +550,7 @@ const CreateStationDialog: React.FC<{ + onCheckedChange={(checked) => setFormData(prev => ({ ...prev, enabled: checked })) } /> @@ -589,12 +589,12 @@ const EditStationDialog: React.FC<{ enabled: station.enabled, }); const [submitting, setSubmitting] = useState(false); - + const { t } = useTranslation(); const handleSubmit = async (e: React.FormEvent) => { e.preventDefault(); - + if (!formData.name.trim()) { alert(t('relayStation.nameRequired')); return; @@ -630,12 +630,12 @@ const EditStationDialog: React.FC<{ placeholder={t('relayStation.namePlaceholder')} />
- +