From 133cf772377af5ba07ec3f4f425fc0846d097616 Mon Sep 17 00:00:00 2001 From: lk Date: Mon, 9 Sep 2024 18:46:07 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AF=81=E4=B9=A6=E5=A4=A7=E9=83=A8=E5=88=86?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/websites/cert/apply.tsx | 27 +++++++++++++++++-- src/routes.tsx | 11 ++++++++ src/service/websites.ts | 8 ++++-- src/store/websites/cert.ts | 56 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 98 insertions(+), 4 deletions(-) diff --git a/src/pages/websites/cert/apply.tsx b/src/pages/websites/cert/apply.tsx index 9ec33ea..9b309c7 100644 --- a/src/pages/websites/cert/apply.tsx +++ b/src/pages/websites/cert/apply.tsx @@ -27,6 +27,7 @@ import { TagOutlined, } from "@ant-design/icons"; import { useQueryClient } from "@tanstack/react-query"; +import { useNavigate } from "@tanstack/react-router"; const i18nPrefix = "cert.apply"; const DomainsInput = (props: { domains; setDomains; currentDomainMod; setCurrentDomainMod; currentStep }) => { @@ -132,10 +133,16 @@ const StatusTable = (props: { value: string; setCurrentStep; setDns_list }) => { setForceUpdate((prev) => prev + 1); }; - const { mutate: addCnameFun, isPending: addCnamePending, isSuccess } = useAtomValue(certAddCnameAtom); + const { + data: addCnameData, + mutate: addCnameFun, + isPending, + isSuccess: isAddSuccess, + } = useAtomValue(certAddCnameAtom); const handleAddCname = async (info: any) => { addCnameFun(info); }; + // const { // data: dnsVerifyStatus, // isFetching: isVerifyFetching, @@ -360,6 +367,7 @@ const Apply = () => { const { styles } = useStyle(); const [form] = Form.useForm(); const { + data: applyTxtCertificateData, mutate: applyTxtCertificateFun, isPending: applyTxtCertificatePending, isSuccess: applyTxtCertificateIsSuccess, @@ -379,7 +387,7 @@ const Apply = () => { }; const applyTxtCertificateClick = () => { const data: Req_ApplyTxtCertificate = { - is_sync: true, + is_sync: false, acme_type: acme_type, key_rsa: key_rsa, dns_list: dns_list, @@ -394,6 +402,21 @@ const Apply = () => { form.setFieldsValue({ algorithm: key_rsa }); }, [domains, acme_type, key_rsa, form]); + const navigate = useNavigate(); + + useEffect(() => { + if (applyTxtCertificateIsSuccess) { + const status = (applyTxtCertificateData as any)?.data?.item[0]?.status || 0; + const status_txt = (applyTxtCertificateData as any)?.data?.item[0]?.status_txt||""; + if (status || status === 5) { + message.error(status_txt); + } else { + message.success(status_txt); + navigate({ to: `/client/cert/management` }); // 确保路径正确 + } + } + }, [applyTxtCertificateIsSuccess]); + return ( emptyRoute, } as any) + // // const menusRoute = createRoute({ // getParentRoute: () => layoutAuthRoute, @@ -302,6 +304,15 @@ const routeTree = rootRoute.addChildren( loginRoute, emptyRoute, + // 添加新的自定义路由 + createRoute({ + getParentRoute: () => rootRoute, + path: '/login2', + component: Login2, + }), + + + //不带权限Layout layoutNormalRoute.addChildren([ notAuthRoute, diff --git a/src/service/websites.ts b/src/service/websites.ts index 2f7f1fc..81ba014 100644 --- a/src/service/websites.ts +++ b/src/service/websites.ts @@ -23,17 +23,21 @@ const websitesServ = { renewCertificate: async (params: any) => { return request.post("/website/cert/renew_certificate", params); }, + // 删除证书 + deletesCertificate: async (params: any) => { + return request.post("/cert/apply/deletes", params); + }, // 添加记录 addCnameCertificate: async (params: any) => { return request.post("/cert/apply/add/cname", params); }, // 下载证书 downloadCertificate: async (params: any) => { - return request.post("/website/cert/download_certificate", params); + return request.post("/cert/apply/download", params); }, // 获取证书申请日志 getCertificateLogs: async (params: any) => { - return request.get("/website/cert/get_certificate_logs", { params }); + return request.post("/cert/log", params); }, applyTxtCertificate: async (params: any) => { return request.post("/cert/apply/resolve", params); diff --git a/src/store/websites/cert.ts b/src/store/websites/cert.ts index a34458c..682f63e 100644 --- a/src/store/websites/cert.ts +++ b/src/store/websites/cert.ts @@ -50,6 +50,24 @@ export const bandTypes = [ }, ]; +//=========================证书日志 +export interface req_CertLogs { + log_id: number; + log_type: string; + websocket: boolean; + log_pos: number; +} + +//=========================下载证书 +export type Req_DownloadCert = { + id: number; + cert_format: string; +}; +//=========================删除证书 +export type Req_DeletesCert = { + ids: number[]; +}; + export const algorithmTypes = [ { label: "RSA", value: "RSA" }, { label: "ECC", value: "ECC" }, @@ -153,6 +171,7 @@ export const certAddCnameAtom = atomWithMutation(() => }); export const applyTxtCertificateAtom = atomWithMutation(() => { + // status 3:进行中,5:失败,9:成功 return { mutationKey: ["applyTxtCertificate"], mutationFn: async (data: Req_ApplyTxtCertificate) => { @@ -164,6 +183,43 @@ export const applyTxtCertificateAtom = atomWithMutation + atomWithQuery(() => { + return { + queryKey: ["getCertificateLogs"], + queryFn: async () => { + return await websitesServ.cert.getCertificateLogs(data); + }, + select: (res) => { + return res.data; + }, + }; + }); + +export const downloadCertificateAtom = (params: Req_DownloadCert) => + atomWithQuery(() => { + return { + queryKey: ["downloadCertificate", params], + queryFn: async ({ queryKey: [, params] }) => { + return await websitesServ.cert.downloadCertificate(params); + }, + select: (res) => { + return res.data; + }, + }; + }); +export const deletesCertificateAtom = (params: Req_DeletesCert) => + atomWithQuery(() => { + return { + queryKey: ["deletesCertificate", params], + queryFn: async ({ queryKey: [, params] }) => { + return await websitesServ.cert.deletesCertificate(params); + }, + select: (res) => { + return res.data; + }, + }; + }); //==================================================================================================================================================kelis // //certApple