Files
CC-Switch/src/components/deeplink/McpConfirmation.tsx
T
Jason fd46dde3fb fix(i18n): add missing translation keys for deeplink confirmation components
- Add i18n support to McpConfirmation, PromptConfirmation, SkillConfirmation
- Add nested translation keys: deeplink.mcp.*, deeplink.prompt.*, deeplink.skill.*
- Replace all hardcoded Chinese strings with t() function calls
- Ensure consistent localization across all deeplink import dialogs
2025-11-25 09:52:19 +08:00

76 lines
2.4 KiB
TypeScript
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { useMemo } from "react";
import { useTranslation } from "react-i18next";
import { DeepLinkImportRequest } from "../../lib/api/deeplink";
import { decodeBase64Utf8 } from "../../lib/utils/base64";
export function McpConfirmation({
request,
}: {
request: DeepLinkImportRequest;
}) {
const { t } = useTranslation();
const mcpServers = useMemo(() => {
if (!request.config) return null;
try {
const decoded = decodeBase64Utf8(request.config);
const parsed = JSON.parse(decoded);
return parsed.mcpServers || {};
} catch (e) {
console.error("Failed to parse MCP config:", e);
return null;
}
}, [request.config]);
const targetApps = request.apps?.split(",") || [];
const serverCount = Object.keys(mcpServers || {}).length;
return (
<div className="space-y-4">
<h3 className="text-lg font-semibold">{t("deeplink.mcp.title")}</h3>
<div>
<label className="block text-sm font-medium text-muted-foreground">
{t("deeplink.mcp.targetApps")}
</label>
<div className="mt-1 flex gap-2 flex-wrap">
{targetApps.map((app) => (
<span
key={app}
className="px-2 py-1 bg-primary/10 text-primary text-xs rounded capitalize"
>
{app.trim()}
</span>
))}
</div>
</div>
<div>
<label className="block text-sm font-medium text-muted-foreground">
{t("deeplink.mcp.serverCount", { count: serverCount })}
</label>
<div className="mt-1 space-y-2 max-h-64 overflow-auto border rounded p-2 bg-muted/30">
{mcpServers &&
Object.entries(mcpServers).map(([id, spec]: [string, any]) => (
<div key={id} className="p-2 bg-background rounded border">
<div className="font-semibold text-sm">{id}</div>
<div className="text-xs text-muted-foreground mt-1 font-mono truncate">
{spec.command
? `Command: ${spec.command} `
: `URL: ${spec.url} `}
</div>
</div>
))}
</div>
</div>
{request.enabled && (
<div className="text-yellow-600 dark:text-yellow-500 text-sm flex items-center gap-2">
<span></span>
<span>{t("deeplink.mcp.enabledWarning")}</span>
</div>
)}
</div>
);
}