修改错误

This commit is contained in:
2025-08-08 00:44:23 +08:00
parent ef2e30401e
commit e903e6a3d1
2 changed files with 41 additions and 41 deletions

View File

@@ -9,22 +9,22 @@ import { Textarea } from '@/components/ui/textarea';
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select'; import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select';
import { Switch } from '@/components/ui/switch'; import { Switch } from '@/components/ui/switch';
import { useTranslation } from '@/hooks/useTranslation'; import { useTranslation } from '@/hooks/useTranslation';
import { import {
RelayStation, RelayStation,
CreateRelayStationRequest, CreateRelayStationRequest,
UpdateRelayStationRequest, UpdateRelayStationRequest,
RelayStationAdapter, RelayStationAdapter,
AuthMethod, AuthMethod,
ConnectionTestResult, ConnectionTestResult,
api api
} from '@/lib/api'; } from '@/lib/api';
import { import {
Plus, Plus,
Edit, Edit,
Trash2, Trash2,
Globe, Globe,
CheckCircle, CheckCircle,
XCircle, XCircle,
Wifi, Wifi,
WifiOff, WifiOff,
Server, Server,
@@ -48,7 +48,7 @@ const RelayStationManager: React.FC<RelayStationManagerProps> = ({ onBack }) =>
const [togglingEnable, setTogglingEnable] = useState<Record<string, boolean>>({}); const [togglingEnable, setTogglingEnable] = useState<Record<string, boolean>>({});
const [currentConfig, setCurrentConfig] = useState<Record<string, string | null>>({}); const [currentConfig, setCurrentConfig] = useState<Record<string, string | null>>({});
const [loadingConfig, setLoadingConfig] = useState(false); const [loadingConfig, setLoadingConfig] = useState(false);
const { t } = useTranslation(); const { t } = useTranslation();
// 加载中转站列表 // 加载中转站列表
@@ -96,7 +96,7 @@ const RelayStationManager: React.FC<RelayStationManagerProps> = ({ onBack }) =>
setTestingConnections(prev => ({ ...prev, [stationId]: true })); setTestingConnections(prev => ({ ...prev, [stationId]: true }));
const result = await api.relayStationTestConnection(stationId); const result = await api.relayStationTestConnection(stationId);
setConnectionTests(prev => ({ ...prev, [stationId]: result })); setConnectionTests(prev => ({ ...prev, [stationId]: result }));
if (result.success) { if (result.success) {
alert(t('relayStation.connectionSuccess')); alert(t('relayStation.connectionSuccess'));
} else { } else {
@@ -113,7 +113,7 @@ const RelayStationManager: React.FC<RelayStationManagerProps> = ({ onBack }) =>
// 删除中转站 // 删除中转站
const deleteStation = async (stationId: string) => { const deleteStation = async (stationId: string) => {
if (!confirm(t('relayStation.deleteConfirm'))) return; if (!confirm(t('relayStation.deleteConfirm'))) return;
try { try {
await api.relayStationDelete(stationId); await api.relayStationDelete(stationId);
alert(t('relayStation.deleteSuccess')); alert(t('relayStation.deleteSuccess'));
@@ -156,7 +156,7 @@ const RelayStationManager: React.FC<RelayStationManagerProps> = ({ onBack }) =>
const getStatusBadge = (station: RelayStation) => { const getStatusBadge = (station: RelayStation) => {
const enabled = station.enabled; const enabled = station.enabled;
const isToggling = togglingEnable[station.id]; const isToggling = togglingEnable[station.id];
return ( return (
<div className="flex items-center gap-2"> <div className="flex items-center gap-2">
<Switch <Switch
@@ -208,7 +208,7 @@ const RelayStationManager: React.FC<RelayStationManagerProps> = ({ onBack }) =>
</Button> </Button>
</DialogTrigger> </DialogTrigger>
<DialogContent className="sm:max-w-[600px]"> <DialogContent className="sm:max-w-[600px]">
<CreateStationDialog <CreateStationDialog
onSuccess={() => { onSuccess={() => {
setShowCreateDialog(false); setShowCreateDialog(false);
loadStations(); loadStations();
@@ -302,7 +302,7 @@ const RelayStationManager: React.FC<RelayStationManagerProps> = ({ onBack }) =>
<Globe className="mr-2 h-4 w-4" /> <Globe className="mr-2 h-4 w-4" />
{station.api_url} {station.api_url}
</div> </div>
{station.description && ( {station.description && (
<p className="text-sm text-muted-foreground"> <p className="text-sm text-muted-foreground">
{station.description} {station.description}
@@ -341,7 +341,7 @@ const RelayStationManager: React.FC<RelayStationManagerProps> = ({ onBack }) =>
)} )}
{t('relayStation.testConnection')} {t('relayStation.testConnection')}
</Button> </Button>
<div className="flex space-x-2"> <div className="flex space-x-2">
<Button <Button
variant="ghost" variant="ghost"
@@ -408,12 +408,12 @@ const CreateStationDialog: React.FC<{
enabled: false, // 默认不启用,需要通过主界面切换 enabled: false, // 默认不启用,需要通过主界面切换
}); });
const [submitting, setSubmitting] = useState(false); const [submitting, setSubmitting] = useState(false);
const { t } = useTranslation(); const { t } = useTranslation();
const handleSubmit = async (e: React.FormEvent) => { const handleSubmit = async (e: React.FormEvent) => {
e.preventDefault(); e.preventDefault();
if (!formData.name.trim()) { if (!formData.name.trim()) {
alert(t('relayStation.nameRequired')); alert(t('relayStation.nameRequired'));
return; return;
@@ -458,12 +458,12 @@ const CreateStationDialog: React.FC<{
placeholder={t('relayStation.namePlaceholder')} placeholder={t('relayStation.namePlaceholder')}
/> />
</div> </div>
<div className="space-y-2"> <div className="space-y-2">
<Label htmlFor="adapter">{t('relayStation.adapterType')}</Label> <Label htmlFor="adapter">{t('relayStation.adapterType')}</Label>
<Select <Select
value={formData.adapter} value={formData.adapter}
onValueChange={(value: RelayStationAdapter) => onValueChange={(value: RelayStationAdapter) =>
setFormData(prev => ({ ...prev, adapter: value })) setFormData(prev => ({ ...prev, adapter: value }))
} }
> >
@@ -498,7 +498,7 @@ const CreateStationDialog: React.FC<{
type="url" type="url"
value={formData.api_url} value={formData.api_url}
onChange={(e) => setFormData(prev => ({ ...prev, api_url: e.target.value }))} onChange={(e) => setFormData(prev => ({ ...prev, api_url: e.target.value }))}
placeholder="https://api.example.com" placeholder="https://api.packycode.com"
/> />
</div> </div>
@@ -507,7 +507,7 @@ const CreateStationDialog: React.FC<{
<Label htmlFor="auth_method">{t('relayStation.authMethod')}</Label> <Label htmlFor="auth_method">{t('relayStation.authMethod')}</Label>
<Select <Select
value={formData.auth_method} value={formData.auth_method}
onValueChange={(value: AuthMethod) => onValueChange={(value: AuthMethod) =>
setFormData(prev => ({ ...prev, auth_method: value })) setFormData(prev => ({ ...prev, auth_method: value }))
} }
> >
@@ -550,7 +550,7 @@ const CreateStationDialog: React.FC<{
<Switch <Switch
id="enabled" id="enabled"
checked={formData.enabled} checked={formData.enabled}
onCheckedChange={(checked) => onCheckedChange={(checked) =>
setFormData(prev => ({ ...prev, enabled: checked })) setFormData(prev => ({ ...prev, enabled: checked }))
} }
/> />
@@ -589,12 +589,12 @@ const EditStationDialog: React.FC<{
enabled: station.enabled, enabled: station.enabled,
}); });
const [submitting, setSubmitting] = useState(false); const [submitting, setSubmitting] = useState(false);
const { t } = useTranslation(); const { t } = useTranslation();
const handleSubmit = async (e: React.FormEvent) => { const handleSubmit = async (e: React.FormEvent) => {
e.preventDefault(); e.preventDefault();
if (!formData.name.trim()) { if (!formData.name.trim()) {
alert(t('relayStation.nameRequired')); alert(t('relayStation.nameRequired'));
return; return;
@@ -630,12 +630,12 @@ const EditStationDialog: React.FC<{
placeholder={t('relayStation.namePlaceholder')} placeholder={t('relayStation.namePlaceholder')}
/> />
</div> </div>
<div className="space-y-2"> <div className="space-y-2">
<Label htmlFor="adapter">{t('relayStation.adapterType')}</Label> <Label htmlFor="adapter">{t('relayStation.adapterType')}</Label>
<Select <Select
value={formData.adapter} value={formData.adapter}
onValueChange={(value: RelayStationAdapter) => onValueChange={(value: RelayStationAdapter) =>
setFormData(prev => ({ ...prev, adapter: value })) setFormData(prev => ({ ...prev, adapter: value }))
} }
> >
@@ -659,7 +659,7 @@ const EditStationDialog: React.FC<{
type="url" type="url"
value={formData.api_url} value={formData.api_url}
onChange={(e) => setFormData(prev => ({ ...prev, api_url: e.target.value }))} onChange={(e) => setFormData(prev => ({ ...prev, api_url: e.target.value }))}
placeholder="https://api.example.com" placeholder="https://api.packycode.com"
/> />
</div> </div>
@@ -688,4 +688,4 @@ const EditStationDialog: React.FC<{
); );
}; };
export default RelayStationManager; export default RelayStationManager;

View File

@@ -99,11 +99,11 @@ export function WelcomePage({ onNavigate, onNewSession }: WelcomePageProps) {
animate={{ opacity: 1, y: 0 }} animate={{ opacity: 1, y: 0 }}
transition={{ duration: 0.5 }} transition={{ duration: 0.5 }}
> >
<h1 className="text-5xl font-bold mb-4 flex items-center justify-center gap-4 text-white"> <h1 className="text-5xl font-bold mb-4 flex items-center justify-center gap-4 text-foreground">
<ClaudiaLogoMinimal size={56} /> <ClaudiaLogoMinimal size={56} />
{t("app.welcome")} {t("app.welcome")}
</h1> </h1>
<p className="text-white/90 text-xl"> <p className="text-muted-foreground text-xl">
{t("app.tagline")} {t("app.tagline")}
</p> </p>
</motion.div> </motion.div>
@@ -123,7 +123,7 @@ export function WelcomePage({ onNavigate, onNewSession }: WelcomePageProps) {
}} }}
> >
<div <div
className="h-full group bg-white/5 border border-white/10 rounded-lg hover:bg-white/10 hover:border-orange-500/50 transition-all duration-300 cursor-pointer" className="h-full group bg-card/50 border border-border rounded-lg hover:bg-card hover:border-orange-500/50 transition-all duration-300 cursor-pointer"
onClick={() => handleCardClick(feature.view)} onClick={() => handleCardClick(feature.view)}
> >
<div className="p-10"> <div className="p-10">
@@ -132,10 +132,10 @@ export function WelcomePage({ onNavigate, onNewSession }: WelcomePageProps) {
<feature.icon className={`h-10 w-10 ${feature.color}`} strokeWidth={1.5} /> <feature.icon className={`h-10 w-10 ${feature.color}`} strokeWidth={1.5} />
</div> </div>
<div className="flex-1"> <div className="flex-1">
<h2 className="text-2xl font-bold mb-3 text-white group-hover:text-primary transition-colors"> <h2 className="text-2xl font-bold mb-3 text-foreground group-hover:text-primary transition-colors">
{feature.title} {feature.title}
</h2> </h2>
<p className="text-white/80 text-base leading-relaxed"> <p className="text-muted-foreground text-base leading-relaxed">
{feature.subtitle} {feature.subtitle}
</p> </p>
</div> </div>
@@ -161,7 +161,7 @@ export function WelcomePage({ onNavigate, onNewSession }: WelcomePageProps) {
}} }}
> >
<div <div
className="h-32 group bg-white/5 border border-white/10 rounded-lg hover:bg-white/10 hover:border-orange-500/50 transition-all duration-300 cursor-pointer" className="h-32 group bg-card/50 border border-border rounded-lg hover:bg-card hover:border-orange-500/50 transition-all duration-300 cursor-pointer"
onClick={() => handleCardClick(feature.view)} onClick={() => handleCardClick(feature.view)}
> >
<div className="h-full flex items-center p-6"> <div className="h-full flex items-center p-6">
@@ -169,10 +169,10 @@ export function WelcomePage({ onNavigate, onNewSession }: WelcomePageProps) {
<feature.icon className={`h-7 w-7 ${feature.color}`} strokeWidth={1.5} /> <feature.icon className={`h-7 w-7 ${feature.color}`} strokeWidth={1.5} />
</div> </div>
<div className="flex-1 min-w-0"> <div className="flex-1 min-w-0">
<h3 className="text-sm font-semibold mb-1 text-white group-hover:text-primary transition-colors truncate"> <h3 className="text-sm font-semibold mb-1 text-foreground group-hover:text-primary transition-colors truncate">
{feature.title} {feature.title}
</h3> </h3>
<p className="text-xs text-white/70 line-clamp-2"> <p className="text-xs text-muted-foreground line-clamp-2">
{feature.subtitle} {feature.subtitle}
</p> </p>
</div> </div>