mirror of
https://github.com/farion1231/cc-switch.git
synced 2026-07-25 13:45:03 +08:00
2fb3b5405a
- Add health status translations (operational, degraded, failed, circuitOpen) - Add proxy panel translations (serviceAddress, stats, stopped state) - Add usage filter translations (appType, statusCode, searchPlaceholder) - Add providerIcon click hints (clickToChange, clickToSelect) - Add config load error translations for main.tsx - Complete Japanese proxy section (failoverQueue, autoFailover) - Fix date/time locale in usage charts and tables - Use t() function in all hardcoded UI strings
52 lines
1.4 KiB
TypeScript
52 lines
1.4 KiB
TypeScript
import React from "react";
|
|
import { cn } from "@/lib/utils";
|
|
import type { HealthStatus } from "@/lib/api/model-test";
|
|
import { useTranslation } from "react-i18next";
|
|
|
|
interface HealthStatusIndicatorProps {
|
|
status: HealthStatus;
|
|
responseTimeMs?: number;
|
|
className?: string;
|
|
}
|
|
|
|
const statusConfig = {
|
|
operational: {
|
|
color: "bg-emerald-500",
|
|
labelKey: "health.operational",
|
|
labelFallback: "正常",
|
|
textColor: "text-emerald-600 dark:text-emerald-400",
|
|
},
|
|
degraded: {
|
|
color: "bg-yellow-500",
|
|
labelKey: "health.degraded",
|
|
labelFallback: "降级",
|
|
textColor: "text-yellow-600 dark:text-yellow-400",
|
|
},
|
|
failed: {
|
|
color: "bg-red-500",
|
|
labelKey: "health.failed",
|
|
labelFallback: "失败",
|
|
textColor: "text-red-600 dark:text-red-400",
|
|
},
|
|
};
|
|
|
|
export const HealthStatusIndicator: React.FC<HealthStatusIndicatorProps> = ({
|
|
status,
|
|
responseTimeMs,
|
|
className,
|
|
}) => {
|
|
const { t } = useTranslation();
|
|
const config = statusConfig[status];
|
|
const label = t(config.labelKey, { defaultValue: config.labelFallback });
|
|
|
|
return (
|
|
<div className={cn("flex items-center gap-2", className)}>
|
|
<div className={cn("w-2 h-2 rounded-full", config.color)} />
|
|
<span className={cn("text-xs font-medium", config.textColor)}>
|
|
{label}
|
|
{responseTimeMs !== undefined && ` (${responseTimeMs}ms)`}
|
|
</span>
|
|
</div>
|
|
);
|
|
};
|