mirror of
https://github.com/farion1231/cc-switch.git
synced 2026-07-26 06:24:32 +08:00
c54515742f
- Add 69 missing translation keys to zh/en/ja (usage, proxy, sessionManager, deeplink, codexConfig, openclaw, circuitBreaker, streamCheck, etc.) - Replace 15 hardcoded Chinese strings in CircuitBreakerConfigPanel with t() calls - Fix ColorPicker component to use i18n for default label - Add i18n interpolation params to ProxyToggle tooltip translations - All three language files synchronized at 1838 keys
80 lines
1.9 KiB
TypeScript
80 lines
1.9 KiB
TypeScript
import React from "react";
|
|
import { Input } from "@/components/ui/input";
|
|
import { Label } from "@/components/ui/label";
|
|
import { cn } from "@/lib/utils";
|
|
import { useTranslation } from "react-i18next";
|
|
|
|
interface ColorPickerProps {
|
|
value?: string;
|
|
onValueChange: (color: string) => void;
|
|
label?: string;
|
|
presets?: string[];
|
|
}
|
|
|
|
const DEFAULT_PRESETS = [
|
|
"#00A67E",
|
|
"#D4915D",
|
|
"#4285F4",
|
|
"#FF6A00",
|
|
"#00A4FF",
|
|
"#FF9900",
|
|
"#0078D4",
|
|
"#FF0000",
|
|
"#1E88E5",
|
|
"#6366F1",
|
|
"#0F62FE",
|
|
"#2932E1",
|
|
];
|
|
|
|
export const ColorPicker: React.FC<ColorPickerProps> = ({
|
|
value = "#4285F4",
|
|
onValueChange,
|
|
label,
|
|
presets = DEFAULT_PRESETS,
|
|
}) => {
|
|
const { t } = useTranslation();
|
|
const displayLabel = label ?? t("providerIcon.color", "图标颜色");
|
|
return (
|
|
<div className="space-y-3">
|
|
<Label>{displayLabel}</Label>
|
|
|
|
{/* 颜色预设 */}
|
|
<div className="grid grid-cols-6 gap-2">
|
|
{presets.map((color) => (
|
|
<button
|
|
key={color}
|
|
type="button"
|
|
onClick={() => onValueChange(color)}
|
|
className={cn(
|
|
"w-full aspect-square rounded-lg border-2 transition-all",
|
|
"hover:scale-110 hover:shadow-lg",
|
|
value === color
|
|
? "border-primary ring-2 ring-primary/20"
|
|
: "border-border",
|
|
)}
|
|
style={{ backgroundColor: color }}
|
|
title={color}
|
|
/>
|
|
))}
|
|
</div>
|
|
|
|
{/* 自定义颜色输入 */}
|
|
<div className="flex items-center gap-2">
|
|
<Input
|
|
type="color"
|
|
value={value}
|
|
onChange={(e) => onValueChange(e.target.value)}
|
|
className="w-16 h-10 p-1 cursor-pointer"
|
|
/>
|
|
<Input
|
|
type="text"
|
|
value={value}
|
|
onChange={(e) => onValueChange(e.target.value)}
|
|
placeholder="#4285F4"
|
|
className="flex-1 font-mono"
|
|
/>
|
|
</div>
|
|
</div>
|
|
);
|
|
};
|