From 05148eeef860d33232874a640dbd67ba43ac5686 Mon Sep 17 00:00:00 2001
From: zhou zhou <3272660260@qq.com>
Date: 星期四, 19 三月 2026 12:51:49 +0800
Subject: [PATCH] #AI.配置中心可运营化
---
rsf-admin/src/page/system/aiParam/AiParamForm.jsx | 81 +++++++++++++++++++++++++++++++++++++++-
1 files changed, 79 insertions(+), 2 deletions(-)
diff --git a/rsf-admin/src/page/system/aiParam/AiParamForm.jsx b/rsf-admin/src/page/system/aiParam/AiParamForm.jsx
index 07fbd25..09eface 100644
--- a/rsf-admin/src/page/system/aiParam/AiParamForm.jsx
+++ b/rsf-admin/src/page/system/aiParam/AiParamForm.jsx
@@ -1,16 +1,69 @@
-import React from "react";
+import React, { useState } from "react";
import {
BooleanInput,
+ FormDataConsumer,
NumberInput,
SelectInput,
TextInput,
+ useNotify,
} from "react-admin";
-import { Grid, Typography } from "@mui/material";
+import { Alert, Button, Grid, Stack, Typography } from "@mui/material";
import StatusSelectInput from "@/page/components/StatusSelectInput";
+import { validateAiParamDraft } from "@/api/ai/configCenter";
const providerChoices = [
{ id: "OPENAI_COMPATIBLE", name: "OPENAI_COMPATIBLE" },
];
+
+const AiParamValidateSection = ({ formData, readOnly }) => {
+ const notify = useNotify();
+ const [loading, setLoading] = useState(false);
+ const [result, setResult] = useState(null);
+
+ const handleValidate = async () => {
+ setLoading(true);
+ try {
+ const data = await validateAiParamDraft(formData);
+ setResult(data);
+ notify(data?.message || "AI 鍙傛暟楠岃瘉鎴愬姛");
+ } catch (error) {
+ const nextResult = {
+ status: "INVALID",
+ message: error?.message || "AI 鍙傛暟楠岃瘉澶辫触",
+ };
+ setResult(nextResult);
+ notify(nextResult.message, { type: "error" });
+ } finally {
+ setLoading(false);
+ }
+ };
+
+ return (
+ <>
+ {!readOnly && (
+ <Grid item xs={12}>
+ <Stack direction="row" spacing={1} alignItems="center">
+ <Button variant="outlined" onClick={handleValidate} disabled={loading}>
+ {loading ? "楠岃瘉涓�..." : "淇濆瓨鍓嶉獙璇�"}
+ </Button>
+ <Typography variant="body2" color="text.secondary">
+ 浼氱洿鎺ユ牎楠屽綋鍓� Base URL銆丄PI Key 涓庢ā鍨嬫槸鍚﹀彲璋冪敤銆�
+ </Typography>
+ </Stack>
+ </Grid>
+ )}
+ {result && (
+ <Grid item xs={12}>
+ <Alert severity={result.status === "VALID" ? "success" : "error"}>
+ {result.message}
+ {result.elapsedMs ? ` 路 ${result.elapsedMs} ms` : ""}
+ {result.validatedAt ? ` 路 ${result.validatedAt}` : ""}
+ </Alert>
+ </Grid>
+ )}
+ </>
+ );
+};
const AiParamForm = ({ readOnly = false }) => (
<Grid container spacing={2} width={{ xs: "100%", xl: "80%" }}>
@@ -53,6 +106,30 @@
<Grid item xs={12}>
<TextInput source="memo" label="澶囨敞" fullWidth multiline minRows={3} disabled={readOnly} />
</Grid>
+ <FormDataConsumer>
+ {({ formData }) => <AiParamValidateSection formData={formData} readOnly={readOnly} />}
+ </FormDataConsumer>
+ <Grid item xs={12}>
+ <Typography variant="h6">杩愯涓庡璁′俊鎭�</Typography>
+ </Grid>
+ <Grid item xs={12} md={3}>
+ <TextInput source="validateStatus" label="鏈�杩戞牎楠岀姸鎬�" fullWidth disabled />
+ </Grid>
+ <Grid item xs={12} md={3}>
+ <TextInput source="lastValidateElapsedMs" label="鏈�杩戞牎楠岃�楁椂(ms)" fullWidth disabled />
+ </Grid>
+ <Grid item xs={12} md={3}>
+ <TextInput source="lastValidateTime$" label="鏈�杩戞牎楠屾椂闂�" fullWidth disabled />
+ </Grid>
+ <Grid item xs={12} md={3}>
+ <TextInput source="updateBy" label="鏈�杩戞洿鏂颁汉" fullWidth disabled />
+ </Grid>
+ <Grid item xs={12}>
+ <TextInput source="lastValidateMessage" label="鏈�杩戞牎楠岀粨鏋�" fullWidth multiline minRows={3} disabled />
+ </Grid>
+ <Grid item xs={12}>
+ <TextInput source="updateTime$" label="鏈�杩戞洿鏂版椂闂�" fullWidth disabled />
+ </Grid>
</Grid>
);
--
Gitblit v1.9.1