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/aiCallLog/AiCallLogList.jsx |  104 ++++++++++++++++++++++++++-------------------------
 1 files changed, 53 insertions(+), 51 deletions(-)

diff --git a/rsf-admin/src/page/system/aiCallLog/AiCallLogList.jsx b/rsf-admin/src/page/system/aiCallLog/AiCallLogList.jsx
index abb70b1..d3f73e5 100644
--- a/rsf-admin/src/page/system/aiCallLog/AiCallLogList.jsx
+++ b/rsf-admin/src/page/system/aiCallLog/AiCallLogList.jsx
@@ -8,6 +8,7 @@
     TopToolbar,
     useListContext,
     useNotify,
+    useTranslate,
 } from "react-admin";
 import {
     Alert,
@@ -32,12 +33,12 @@
 
 const filters = [
     <SearchInput source="condition" alwaysOn />,
-    <TextInput source="requestId" label="璇锋眰ID" />,
-    <TextInput source="promptCode" label="Prompt 缂栫爜" />,
-    <TextInput source="userId" label="鐢ㄦ埛ID" />,
+    <TextInput source="requestId" label="ai.observe.fields.requestId" />,
+    <TextInput source="promptCode" label="ai.observe.fields.promptCode" />,
+    <TextInput source="userId" label="ai.observe.fields.userId" />,
     <SelectInput
         source="status"
-        label="鐘舵��"
+        label="common.field.status"
         choices={[
             { id: "RUNNING", name: "RUNNING" },
             { id: "COMPLETED", name: "COMPLETED" },
@@ -48,6 +49,7 @@
 ];
 
 const ObserveSummary = () => {
+    const translate = useTranslate();
     const [stats, setStats] = useState(null);
     const [loading, setLoading] = useState(true);
     const [error, setError] = useState("");
@@ -64,7 +66,7 @@
             })
             .catch((err) => {
                 if (active) {
-                    setError(err?.message || "鑾峰彇 AI 瑙傛祴缁熻澶辫触");
+                    setError(err?.message || translate("ai.observe.summary.fetchFailed"));
                 }
             })
             .finally(() => {
@@ -83,9 +85,9 @@
                 <CardContent>
                     <Stack direction="row" justifyContent="space-between" alignItems="center" mb={2}>
                         <Box>
-                            <Typography variant="h6">瑙傛祴鎬昏</Typography>
+                            <Typography variant="h6">{translate("ai.observe.summary.title")}</Typography>
                             <Typography variant="body2" color="text.secondary">
-                                褰撳墠绉熸埛涓嬬殑 AI 瀵硅瘽璋冪敤涓� MCP 宸ュ叿璋冪敤缁熻銆�
+                                {translate("ai.observe.summary.description")}
                             </Typography>
                         </Box>
                         {loading && <CircularProgress size={24} />}
@@ -94,31 +96,31 @@
                     {!loading && !error && stats && (
                         <Grid container spacing={2}>
                             <Grid item xs={12} md={3}>
-                                <Typography variant="caption" color="text.secondary">AI 璋冪敤閲�</Typography>
+                                <Typography variant="caption" color="text.secondary">{translate("ai.observe.summary.callCount")}</Typography>
                                 <Typography variant="h5">{stats.callCount ?? 0}</Typography>
                                 <Typography variant="body2" color="text.secondary">
-                                    鎴愬姛 {stats.successCount ?? 0} / 澶辫触 {stats.failureCount ?? 0}
+                                    {translate("ai.observe.summary.successFailure", { success: stats.successCount ?? 0, failure: stats.failureCount ?? 0 })}
                                 </Typography>
                             </Grid>
                             <Grid item xs={12} md={3}>
-                                <Typography variant="caption" color="text.secondary">骞冲潎鑰楁椂</Typography>
+                                <Typography variant="caption" color="text.secondary">{translate("ai.observe.summary.avgElapsed")}</Typography>
                                 <Typography variant="h5">{stats.avgElapsedMs ?? 0} ms</Typography>
                                 <Typography variant="body2" color="text.secondary">
-                                    棣栧寘 {stats.avgFirstTokenLatencyMs ?? 0} ms
+                                    {translate("ai.observe.summary.firstToken", { value: stats.avgFirstTokenLatencyMs ?? 0 })}
                                 </Typography>
                             </Grid>
                             <Grid item xs={12} md={3}>
-                                <Typography variant="caption" color="text.secondary">Token 浣跨敤</Typography>
+                                <Typography variant="caption" color="text.secondary">{translate("ai.observe.summary.tokenUsage")}</Typography>
                                 <Typography variant="h5">{stats.totalTokens ?? 0}</Typography>
                                 <Typography variant="body2" color="text.secondary">
-                                    骞冲潎 {stats.avgTotalTokens ?? 0}
+                                    {translate("ai.observe.summary.avgToken", { value: stats.avgTotalTokens ?? 0 })}
                                 </Typography>
                             </Grid>
                             <Grid item xs={12} md={3}>
-                                <Typography variant="caption" color="text.secondary">宸ュ叿鎴愬姛鐜�</Typography>
+                                <Typography variant="caption" color="text.secondary">{translate("ai.observe.summary.toolSuccessRate")}</Typography>
                                 <Typography variant="h5">{Number(stats.toolSuccessRate || 0).toFixed(2)}%</Typography>
                                 <Typography variant="body2" color="text.secondary">
-                                    璋冪敤 {stats.toolCallCount ?? 0} / 澶辫触 {stats.toolFailureCount ?? 0}
+                                    {translate("ai.observe.summary.toolCallFailure", { call: stats.toolCallCount ?? 0, failure: stats.toolFailureCount ?? 0 })}
                                 </Typography>
                             </Grid>
                         </Grid>
@@ -129,21 +131,22 @@
     );
 };
 
-const resolveStatusChip = (status) => {
+const resolveStatusChip = (status, translate) => {
     if (status === "COMPLETED") {
-        return { color: "success", label: "鎴愬姛" };
+        return { color: "success", label: translate("ai.observe.status.completed") };
     }
     if (status === "FAILED") {
-        return { color: "error", label: "澶辫触" };
+        return { color: "error", label: translate("ai.observe.status.failed") };
     }
     if (status === "ABORTED") {
-        return { color: "warning", label: "涓柇" };
+        return { color: "warning", label: translate("ai.observe.status.aborted") };
     }
     return { color: "default", label: status || "--" };
 };
 
 const AiCallLogDetailDialog = ({ record, open, onClose }) => {
     const notify = useNotify();
+    const translate = useTranslate();
     const [logs, setLogs] = useState([]);
     const [loading, setLoading] = useState(false);
 
@@ -161,7 +164,7 @@
             })
             .catch((error) => {
                 if (active) {
-                    notify(error?.message || "鑾峰彇 MCP 璋冪敤鏃ュ織澶辫触", { type: "error" });
+                    notify(error?.message || translate("ai.observe.detail.mcpLogsFailed"), { type: "error" });
                 }
             })
             .finally(() => {
@@ -180,35 +183,35 @@
 
     return (
         <Dialog open={open} onClose={onClose} fullWidth maxWidth="lg">
-            <DialogTitle>AI 璋冪敤璇︽儏</DialogTitle>
+            <DialogTitle>{translate("ai.observe.detail.title")}</DialogTitle>
             <DialogContent dividers>
                 <Grid container spacing={2}>
                     <Grid item xs={12} md={6}>
-                        <Typography variant="caption" color="text.secondary">璇锋眰ID</Typography>
+                        <Typography variant="caption" color="text.secondary">{translate("ai.observe.fields.requestId")}</Typography>
                         <Typography variant="body2">{record.requestId || "--"}</Typography>
                     </Grid>
                     <Grid item xs={12} md={3}>
-                        <Typography variant="caption" color="text.secondary">鐢ㄦ埛ID</Typography>
+                        <Typography variant="caption" color="text.secondary">{translate("ai.observe.fields.userId")}</Typography>
                         <Typography variant="body2">{record.userId || "--"}</Typography>
                     </Grid>
                     <Grid item xs={12} md={3}>
-                        <Typography variant="caption" color="text.secondary">浼氳瘽ID</Typography>
+                        <Typography variant="caption" color="text.secondary">{translate("ai.observe.fields.sessionId")}</Typography>
                         <Typography variant="body2">{record.sessionId || "--"}</Typography>
                     </Grid>
                     <Grid item xs={12} md={4}>
-                        <Typography variant="caption" color="text.secondary">Prompt</Typography>
+                        <Typography variant="caption" color="text.secondary">{translate("ai.common.prompt")}</Typography>
                         <Typography variant="body2">{record.promptName || "--"} / {record.promptCode || "--"}</Typography>
                     </Grid>
                     <Grid item xs={12} md={4}>
-                        <Typography variant="caption" color="text.secondary">妯″瀷</Typography>
+                        <Typography variant="caption" color="text.secondary">{translate("ai.common.model")}</Typography>
                         <Typography variant="body2">{record.model || "--"}</Typography>
                     </Grid>
                     <Grid item xs={12} md={4}>
-                        <Typography variant="caption" color="text.secondary">鐘舵��</Typography>
+                        <Typography variant="caption" color="text.secondary">{translate("common.field.status")}</Typography>
                         <Typography variant="body2">{record.status || "--"}</Typography>
                     </Grid>
                     <Grid item xs={12}>
-                        <Typography variant="caption" color="text.secondary">MCP 鎸傝浇</Typography>
+                        <Typography variant="caption" color="text.secondary">{translate("ai.observe.fields.mountedMcp")}</Typography>
                         <Typography variant="body2">{record.mountedMcpNames || "--"}</Typography>
                     </Grid>
                     {record.errorMessage && (
@@ -219,12 +222,12 @@
                     <Grid item xs={12}>
                         <Divider sx={{ my: 1 }} />
                         <Stack direction="row" justifyContent="space-between" alignItems="center" mb={1}>
-                            <Typography variant="h6">MCP 宸ュ叿璋冪敤鏃ュ織</Typography>
+                            <Typography variant="h6">{translate("ai.observe.detail.mcpLogs")}</Typography>
                             {loading && <CircularProgress size={20} />}
                         </Stack>
                         {!loading && !logs.length && (
                             <Typography variant="body2" color="text.secondary">
-                                褰撳墠璋冪敤娌℃湁浜х敓 MCP 宸ュ叿鏃ュ織銆�
+                                {translate("ai.observe.detail.noMcpLogs")}
                             </Typography>
                         )}
                         <Stack spacing={1.5}>
@@ -244,13 +247,11 @@
                                                 label={item.status || "--"}
                                             />
                                         </Stack>
-                                        <Typography variant="caption" color="text.secondary">杈撳叆鎽樿</Typography>
+                                        <Typography variant="caption" color="text.secondary">{translate("ai.observe.detail.inputSummary")}</Typography>
                                         <Typography variant="body2" sx={{ whiteSpace: "pre-wrap", wordBreak: "break-word" }}>
                                             {item.inputSummary || "--"}
                                         </Typography>
-                                        <Typography variant="caption" color="text.secondary" display="block" mt={1}>
-                                            杈撳嚭鎽樿 / 閿欒
-                                        </Typography>
+                                        <Typography variant="caption" color="text.secondary" display="block" mt={1}>{translate("ai.observe.detail.outputSummary")}</Typography>
                                         <Typography variant="body2" sx={{ whiteSpace: "pre-wrap", wordBreak: "break-word" }}>
                                             {item.outputSummary || item.errorMessage || "--"}
                                         </Typography>
@@ -262,13 +263,14 @@
                 </Grid>
             </DialogContent>
             <DialogActions>
-                <Button onClick={onClose}>鍏抽棴</Button>
+                <Button onClick={onClose}>{translate("ai.common.close")}</Button>
             </DialogActions>
         </Dialog>
     );
 };
 
 const AiCallLogCards = ({ onView }) => {
+    const translate = useTranslate();
     const { data, isLoading } = useListContext();
     const records = useMemo(() => (Array.isArray(data) ? data : []), [data]);
 
@@ -284,9 +286,9 @@
         return (
             <Box px={2} py={6}>
                 <Card variant="outlined" sx={{ p: 3, textAlign: "center", borderStyle: "dashed" }}>
-                    <Typography variant="subtitle1">鏆傛棤 AI 璋冪敤鏃ュ織</Typography>
+                    <Typography variant="subtitle1">{translate("ai.observe.list.emptyTitle")}</Typography>
                     <Typography variant="body2" color="text.secondary" mt={1}>
-                        鍙戣捣 AI 瀵硅瘽鍚庯紝杩欓噷浼氬睍绀鸿皟鐢ㄧ粺璁″拰瀹¤璁板綍銆�
+                        {translate("ai.observe.list.emptyDescription")}
                     </Typography>
                 </Card>
             </Box>
@@ -297,14 +299,14 @@
         <Box px={2} py={2}>
             <Grid container spacing={2}>
                 {records.map((record) => {
-                    const statusMeta = resolveStatusChip(record.status);
+                    const statusMeta = resolveStatusChip(record.status, translate);
                     return (
                         <Grid item xs={12} md={6} xl={4} key={record.id}>
                             <Card variant="outlined" sx={{ height: "100%", borderRadius: 3, boxShadow: "0 8px 24px rgba(15, 23, 42, 0.06)" }}>
                                 <CardContent sx={{ pb: 1.5 }}>
                                     <Stack direction="row" justifyContent="space-between" alignItems="flex-start" spacing={1}>
                                         <Box>
-                                            <Typography variant="h6">{record.promptName || "AI 瀵硅瘽"}</Typography>
+                                            <Typography variant="h6">{record.promptName || translate("ai.drawer.title")}</Typography>
                                             <Typography variant="body2" color="text.secondary">
                                                 {record.promptCode || "--"} / {record.model || "--"}
                                             </Typography>
@@ -312,31 +314,31 @@
                                         <Chip size="small" color={statusMeta.color} label={statusMeta.label} />
                                     </Stack>
                                     <Stack direction="row" spacing={1} flexWrap="wrap" useFlexGap mt={1.5}>
-                                        <Chip size="small" variant="outlined" label={`鐢ㄦ埛 ${record.userId || "--"}`} />
-                                        <Chip size="small" variant="outlined" label={`鑰楁椂 ${record.elapsedMs ?? 0} ms`} />
-                                        <Chip size="small" variant="outlined" label={`Token ${record.totalTokens ?? 0}`} />
+                                        <Chip size="small" variant="outlined" label={translate("ai.observe.list.userValue", { value: record.userId || "--" })} />
+                                        <Chip size="small" variant="outlined" label={translate("ai.observe.list.elapsedValue", { value: record.elapsedMs ?? 0 })} />
+                                        <Chip size="small" variant="outlined" label={translate("ai.observe.list.tokenValue", { value: record.totalTokens ?? 0 })} />
                                     </Stack>
                                     <Divider sx={{ my: 1.5 }} />
-                                    <Typography variant="caption" color="text.secondary">璇锋眰ID</Typography>
+                                    <Typography variant="caption" color="text.secondary">{translate("ai.observe.fields.requestId")}</Typography>
                                     <Typography variant="body2" sx={{ wordBreak: "break-all" }}>{record.requestId || "--"}</Typography>
-                                    <Typography variant="caption" color="text.secondary" display="block" mt={1.5}>
-                                        MCP / 宸ュ叿璋冪敤
-                                    </Typography>
+                                    <Typography variant="caption" color="text.secondary" display="block" mt={1.5}>{translate("ai.observe.list.mcpToolCalls")}</Typography>
                                     <Typography variant="body2">
-                                        鎸傝浇 {record.mountedMcpCount ?? 0} 涓紝宸ュ叿鎴愬姛 {record.toolSuccessCount ?? 0}锛屽け璐� {record.toolFailureCount ?? 0}
+                                        {translate("ai.observe.list.mcpToolSummary", {
+                                            mcp: record.mountedMcpCount ?? 0,
+                                            success: record.toolSuccessCount ?? 0,
+                                            failure: record.toolFailureCount ?? 0,
+                                        })}
                                     </Typography>
                                     {record.errorMessage && (
                                         <>
-                                            <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.error")}</Typography>
                                             <Typography variant="body2">{record.errorMessage}</Typography>
                                         </>
                                     )}
                                 </CardContent>
                                 <CardActions sx={{ px: 2, pb: 2, pt: 0 }}>
                                     <Button size="small" startIcon={<VisibilityOutlinedIcon />} onClick={() => onView(record)}>
-                                        璇︽儏
+                                        {translate("ai.common.detail")}
                                     </Button>
                                 </CardActions>
                             </Card>

--
Gitblit v1.9.1