From 287a666e1b2bb155e86aa88ebace201d1e8a51f6 Mon Sep 17 00:00:00 2001
From: zhou zhou <3272660260@qq.com>
Date: 星期四, 19 三月 2026 13:26:02 +0800
Subject: [PATCH] #AI.国际化
---
rsf-admin/src/page/system/aiMcpMount/AiMcpMountList.jsx | 73 ++++++++++++++++++------------------
1 files changed, 36 insertions(+), 37 deletions(-)
diff --git a/rsf-admin/src/page/system/aiMcpMount/AiMcpMountList.jsx b/rsf-admin/src/page/system/aiMcpMount/AiMcpMountList.jsx
index 16c5e85..634aa30 100644
--- a/rsf-admin/src/page/system/aiMcpMount/AiMcpMountList.jsx
+++ b/rsf-admin/src/page/system/aiMcpMount/AiMcpMountList.jsx
@@ -9,6 +9,7 @@
useListContext,
useNotify,
useRefresh,
+ useTranslate,
} from "react-admin";
import {
Box,
@@ -39,7 +40,7 @@
<SearchInput source="condition" alwaysOn />,
<SelectInput
source="transportType"
- label="浼犺緭绫诲瀷"
+ label="ai.mcp.fields.transportType"
choices={[
{ id: "SSE_HTTP", name: "SSE_HTTP" },
{ id: "STDIO", name: "STDIO" },
@@ -48,7 +49,7 @@
/>,
<SelectInput
source="status"
- label="鐘舵��"
+ label="common.field.status"
choices={[
{ id: "1", name: "common.enums.statusTrue" },
{ id: "0", name: "common.enums.statusFalse" },
@@ -83,22 +84,23 @@
};
const transportGroups = [
- { key: "BUILTIN", title: "鍐呯疆 MCP", description: "绯荤粺鍐呯疆宸ュ叿鎸傝浇锛岄�傚悎鐩存帴鏆撮湶骞冲彴鑳藉姏銆�" },
- { key: "SSE_HTTP", title: "杩滅▼ SSE MCP", description: "閫氳繃杩滅▼ MCP Server 鎸傝浇澶栭儴宸ュ叿銆�" },
- { key: "STDIO", title: "鏈湴 STDIO MCP", description: "閫氳繃鏈湴鍛戒护杩涚▼鎸傝浇澶栭儴 MCP銆�" },
+ { key: "BUILTIN", titleKey: "ai.mcp.groups.builtin.title", descriptionKey: "ai.mcp.groups.builtin.description" },
+ { key: "SSE_HTTP", titleKey: "ai.mcp.groups.sse.title", descriptionKey: "ai.mcp.groups.sse.description" },
+ { key: "STDIO", titleKey: "ai.mcp.groups.stdio.title", descriptionKey: "ai.mcp.groups.stdio.description" },
];
-const resolveHealthMeta = (record) => {
+const resolveHealthMeta = (record, translate) => {
if (record.healthStatus === "HEALTHY") {
- return { color: "success", label: "姝e父" };
+ return { color: "success", label: translate("ai.mcp.health.healthy") };
}
if (record.healthStatus === "UNHEALTHY") {
- return { color: "error", label: "澶辫触" };
+ return { color: "error", label: translate("ai.mcp.health.unhealthy") };
}
- return { color: "default", label: "鏈祴璇�" };
+ return { color: "default", label: translate("ai.common.notTested") };
};
const AiMcpMountCards = ({ onView, onEdit, onDelete, onConnectivityTest, deleting, testingConnectivityId }) => {
+ const translate = useTranslate();
const { data, isLoading } = useListContext();
const records = useMemo(() => (Array.isArray(data) ? data : []), [data]);
const groupedRecords = useMemo(() => {
@@ -120,9 +122,9 @@
return (
<Box px={2} py={6}>
<Card variant="outlined" sx={{ p: 3, textAlign: "center", borderStyle: "dashed" }}>
- <Typography variant="subtitle1">鏆傛棤 MCP 鎸傝浇</Typography>
+ <Typography variant="subtitle1">{translate("ai.mcp.list.emptyTitle")}</Typography>
<Typography variant="body2" color="text.secondary" mt={1}>
- 鍙互鏂板缓鍐呯疆 MCP銆佽繙绋� SSE 鎸傝浇鎴栨湰鍦� STDIO 鎸傝浇銆�
+ {translate("ai.mcp.list.emptyDescription")}
</Typography>
</Card>
</Box>
@@ -135,14 +137,14 @@
{groupedRecords.map((group) => (
<Box key={group.key}>
<Box mb={1.5}>
- <Typography variant="h6">{group.title}</Typography>
+ <Typography variant="h6">{translate(group.titleKey)}</Typography>
<Typography variant="body2" color="text.secondary">
- {group.description}
+ {translate(group.descriptionKey)}
</Typography>
</Box>
<Grid container spacing={2}>
{group.records.map((record) => {
- const healthMeta = resolveHealthMeta(record);
+ const healthMeta = resolveHealthMeta(record, translate);
return (
<Grid item xs={12} md={6} xl={4} key={record.id}>
<Card
@@ -167,39 +169,35 @@
<Chip
size="small"
color={record.statusBool ? "success" : "default"}
- label={record.statusBool ? "鍚敤" : "鍋滅敤"}
+ label={translate(record.statusBool ? "ai.common.enabled" : "ai.common.disabled")}
/>
<Chip size="small" color={healthMeta.color} label={healthMeta.label} />
</Stack>
</Stack>
<Stack direction="row" spacing={1} flexWrap="wrap" useFlexGap mt={1.5}>
- <Chip size="small" variant="outlined" label={`鎺掑簭 ${record.sort ?? 0}`} />
+ <Chip size="small" variant="outlined" label={translate("ai.mcp.list.sortValue", { value: record.sort ?? 0 })} />
<Chip size="small" variant="outlined" label={`${record.requestTimeoutMs ?? "--"} ms`} />
<Chip size="small" variant="outlined" label={`Init ${record.lastInitElapsedMs ?? "--"} ms`} />
</Stack>
<Divider sx={{ my: 1.5 }} />
- <Typography variant="caption" color="text.secondary">鐩爣</Typography>
+ <Typography variant="caption" color="text.secondary">{translate("ai.common.target")}</Typography>
<Typography variant="body2" sx={{ mt: 0.5, wordBreak: "break-all" }}>
{truncateText(resolveTargetLabel(record), 120)}
</Typography>
- <Typography variant="caption" color="text.secondary" display="block" mt={1.5}>
- 鏈�杩戞祴璇�
- </Typography>
+ <Typography variant="caption" color="text.secondary" display="block" mt={1.5}>{translate("ai.common.lastTest")}</Typography>
<Typography variant="body2">
- {record.lastTestTime$ ? `${record.lastTestTime$} 路 ${truncateText(record.lastTestMessage, 72)}` : "灏氭湭鎵ц杩為�氭�ф祴璇�"}
+ {record.lastTestTime$ ? `${record.lastTestTime$} 路 ${truncateText(record.lastTestMessage, 72)}` : translate("ai.mcp.list.noConnectivityTest")}
</Typography>
- <Typography variant="caption" color="text.secondary" display="block" mt={1.5}>
- 澶囨敞
- </Typography>
+ <Typography variant="caption" color="text.secondary" display="block" mt={1.5}>{translate("common.field.memo")}</Typography>
<Typography variant="body2">{truncateText(record.memo)}</Typography>
</CardContent>
<CardActions sx={{ px: 2, pb: 2, pt: 0, justifyContent: "space-between", alignItems: "flex-start" }}>
<Stack direction="row" spacing={1} flexWrap="wrap" useFlexGap>
<Button size="small" startIcon={<VisibilityOutlinedIcon />} onClick={() => onView(record.id)}>
- 璇︽儏
+ {translate("ai.common.detail")}
</Button>
<Button size="small" startIcon={<EditOutlinedIcon />} onClick={() => onEdit(record.id)}>
- 缂栬緫
+ {translate("common.button.edit")}
</Button>
<Button
size="small"
@@ -207,7 +205,7 @@
onClick={() => onConnectivityTest(record)}
disabled={testingConnectivityId === record.id}
>
- {testingConnectivityId === record.id ? "娴嬭瘯涓�..." : "杩為�氭祴璇�"}
+ {testingConnectivityId === record.id ? translate("ai.common.testing") : translate("ai.mcp.list.connectivityTest")}
</Button>
</Stack>
<Button
@@ -217,7 +215,7 @@
onClick={() => onDelete(record)}
disabled={deleting}
>
- 鍒犻櫎
+ {translate("ai.common.delete")}
</Button>
</CardActions>
</Card>
@@ -233,6 +231,7 @@
};
const AiMcpMountList = () => {
+ const translate = useTranslate();
const notify = useNotify();
const refresh = useRefresh();
const [deleteOne, { isPending: deleting }] = useDelete();
@@ -243,7 +242,7 @@
const closeDialog = () => setDialogState({ open: false, mode: "create", recordId: null });
const handleDelete = (record) => {
- if (!record?.id || !window.confirm(`纭鍒犻櫎鈥�${record.name}鈥濆悧锛焋)) {
+ if (!record?.id || !window.confirm(translate("ai.common.confirmDelete", { name: record.name }))) {
return;
}
deleteOne(
@@ -251,11 +250,11 @@
{ id: record.id },
{
onSuccess: () => {
- notify("鍒犻櫎鎴愬姛");
+ notify(translate("ai.common.deleteSuccess"));
refresh();
},
onError: (error) => {
- notify(error?.message || "鍒犻櫎澶辫触", { type: "error" });
+ notify(error?.message || translate("ai.common.deleteFailed"), { type: "error" });
},
}
);
@@ -268,19 +267,19 @@
setTestingConnectivityId(record.id);
try {
const result = await testMcpConnectivity(record.id);
- notify(result?.message || "杩為�氭�ф祴璇曞畬鎴�");
+ notify(result?.message || translate("ai.mcp.connectivity.success"));
refresh();
} catch (error) {
- notify(error?.message || "杩為�氭�ф祴璇曞け璐�", { type: "error" });
+ notify(error?.message || translate("ai.mcp.connectivity.failed"), { type: "error" });
} finally {
setTestingConnectivityId(null);
}
};
const dialogTitle = {
- create: "鏂板缓 MCP 鎸傝浇",
- edit: "缂栬緫 MCP 鎸傝浇",
- show: "鏌ョ湅 MCP 鎸傝浇璇︽儏",
+ create: translate("ai.mcp.dialog.create"),
+ edit: translate("ai.mcp.dialog.edit"),
+ show: translate("ai.mcp.dialog.show"),
}[dialogState.mode];
return (
@@ -293,7 +292,7 @@
<TopToolbar>
<FilterButton />
<Button variant="contained" startIcon={<AddRoundedIcon />} onClick={() => openDialog("create")}>
- 鏂板缓
+ {translate("ai.common.new")}
</Button>
<MyExportButton />
</TopToolbar>
--
Gitblit v1.9.1