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/aiPrompt/AiPromptForm.jsx | 54 +++++++++++++++++++++++++++++++-----------------------
1 files changed, 31 insertions(+), 23 deletions(-)
diff --git a/rsf-admin/src/page/system/aiPrompt/AiPromptForm.jsx b/rsf-admin/src/page/system/aiPrompt/AiPromptForm.jsx
index 5c6ad35..36051d7 100644
--- a/rsf-admin/src/page/system/aiPrompt/AiPromptForm.jsx
+++ b/rsf-admin/src/page/system/aiPrompt/AiPromptForm.jsx
@@ -3,6 +3,7 @@
FormDataConsumer,
TextInput,
useNotify,
+ useTranslate,
} from "react-admin";
import { Alert, Button, Grid, Stack, TextField, Typography } from "@mui/material";
import StatusSelectInput from "@/page/components/StatusSelectInput";
@@ -10,7 +11,8 @@
const AiPromptPreviewSection = ({ formData }) => {
const notify = useNotify();
- const [input, setInput] = useState("璇峰府鎴戞�荤粨褰撳墠椤甸潰鑳藉仛浠�涔�");
+ const translate = useTranslate();
+ const [input, setInput] = useState(() => translate("ai.prompt.preview.defaultInput"));
const [metadataText, setMetadataText] = useState("{\"path\":\"/system/aiPrompt\"}");
const [preview, setPreview] = useState(null);
const [loading, setLoading] = useState(false);
@@ -25,10 +27,10 @@
metadata,
});
setPreview(data);
- notify("Prompt 棰勮瀹屾垚");
+ notify(translate("ai.prompt.preview.success"));
} catch (error) {
setPreview(null);
- notify(error?.message || "Prompt 棰勮澶辫触", { type: "error" });
+ notify(error?.message || translate("ai.prompt.preview.failed"), { type: "error" });
} finally {
setLoading(false);
}
@@ -37,11 +39,11 @@
return (
<>
<Grid item xs={12}>
- <Typography variant="h6">Prompt 棰勮</Typography>
+ <Typography variant="h6">{translate("ai.prompt.preview.title")}</Typography>
</Grid>
<Grid item xs={12}>
<TextField
- label="绀轰緥杈撳叆"
+ label={translate("ai.prompt.preview.input")}
value={input}
onChange={(event) => setInput(event.target.value)}
fullWidth
@@ -51,7 +53,7 @@
</Grid>
<Grid item xs={12}>
<TextField
- label="绀轰緥鍏冩暟鎹� JSON"
+ label={translate("ai.prompt.preview.metadata")}
value={metadataText}
onChange={(event) => setMetadataText(event.target.value)}
fullWidth
@@ -62,10 +64,10 @@
<Grid item xs={12}>
<Stack direction="row" spacing={1} alignItems="center">
<Button variant="outlined" onClick={handlePreview} disabled={loading}>
- {loading ? "棰勮涓�..." : "棰勮娓叉煋"}
+ {loading ? translate("ai.prompt.preview.loading") : translate("ai.prompt.preview.render")}
</Button>
<Typography variant="body2" color="text.secondary">
- 鐢ㄥ綋鍓嶈〃鍗曞唴瀹规覆鏌� System Prompt 鍜� User Prompt銆�
+ {translate("ai.prompt.preview.description")}
</Typography>
</Stack>
</Grid>
@@ -73,12 +75,14 @@
<>
<Grid item xs={12}>
<Alert severity="success">
- 宸茶В鏋愬彉閲忥細{(preview.resolvedVariables || []).join(", ") || "鏃�"}
+ {translate("ai.prompt.preview.resolvedVariables", {
+ value: (preview.resolvedVariables || []).join(", ") || translate("ai.common.none"),
+ })}
</Alert>
</Grid>
<Grid item xs={12}>
<TextField
- label="娓叉煋鍚庣殑 System Prompt"
+ label={translate("ai.prompt.preview.renderedSystemPrompt")}
value={preview.renderedSystemPrompt || ""}
fullWidth
multiline
@@ -88,7 +92,7 @@
</Grid>
<Grid item xs={12}>
<TextField
- label="娓叉煋鍚庣殑 User Prompt"
+ label={translate("ai.prompt.preview.renderedUserPrompt")}
value={preview.renderedUserPrompt || ""}
fullWidth
multiline
@@ -102,45 +106,49 @@
);
};
-const AiPromptForm = ({ readOnly = false }) => (
+const AiPromptForm = ({ readOnly = false }) => {
+ const translate = useTranslate();
+
+ return (
<Grid container spacing={2} width={{ xs: "100%", xl: "80%" }}>
<Grid item xs={12}>
- <Typography variant="h6">Prompt 閰嶇疆</Typography>
+ <Typography variant="h6">{translate("ai.prompt.form.sections.main")}</Typography>
</Grid>
<Grid item xs={12} md={6}>
- <TextInput source="name" label="鍚嶇О" fullWidth disabled={readOnly} />
+ <TextInput source="name" label="common.field.name" fullWidth disabled={readOnly} />
</Grid>
<Grid item xs={12} md={6}>
- <TextInput source="code" label="缂栫爜" fullWidth disabled={readOnly} />
+ <TextInput source="code" label="ai.prompt.fields.code" fullWidth disabled={readOnly} />
</Grid>
<Grid item xs={12}>
- <TextInput source="scene" label="鍦烘櫙" fullWidth disabled={readOnly} />
+ <TextInput source="scene" label="ai.prompt.fields.scene" fullWidth disabled={readOnly} />
</Grid>
<Grid item xs={12}>
- <TextInput source="systemPrompt" label="System Prompt" fullWidth multiline minRows={6} disabled={readOnly} />
+ <TextInput source="systemPrompt" label="ai.prompt.fields.systemPrompt" fullWidth multiline minRows={6} disabled={readOnly} />
</Grid>
<Grid item xs={12}>
- <TextInput source="userPromptTemplate" label="User Prompt Template" fullWidth multiline minRows={5} disabled={readOnly} />
+ <TextInput source="userPromptTemplate" label="ai.prompt.fields.userPromptTemplate" fullWidth multiline minRows={5} disabled={readOnly} />
</Grid>
<Grid item xs={12} md={6}>
<StatusSelectInput disabled={readOnly} />
</Grid>
<Grid item xs={12}>
- <TextInput source="memo" label="澶囨敞" fullWidth multiline minRows={3} disabled={readOnly} />
+ <TextInput source="memo" label="common.field.memo" fullWidth multiline minRows={3} disabled={readOnly} />
</Grid>
<FormDataConsumer>
{({ formData }) => <AiPromptPreviewSection formData={formData} />}
</FormDataConsumer>
<Grid item xs={12}>
- <Typography variant="h6">杩愯涓庡璁′俊鎭�</Typography>
+ <Typography variant="h6">{translate("ai.prompt.form.sections.runtime")}</Typography>
</Grid>
<Grid item xs={12} md={6}>
- <TextInput source="updateBy" label="鏈�杩戞洿鏂颁汉" fullWidth disabled />
+ <TextInput source="updateBy" label="ai.common.lastUpdatedBy" fullWidth disabled />
</Grid>
<Grid item xs={12} md={6}>
- <TextInput source="updateTime$" label="鏈�杩戞洿鏂版椂闂�" fullWidth disabled />
+ <TextInput source="updateTime$" label="ai.common.lastUpdatedAt" fullWidth disabled />
</Grid>
</Grid>
-);
+ );
+};
export default AiPromptForm;
--
Gitblit v1.9.1