Browse Source

证书大部分接口完成

main
lk 3 months ago
parent
commit
133cf77237
  1. 27
      src/pages/websites/cert/apply.tsx
  2. 11
      src/routes.tsx
  3. 8
      src/service/websites.ts
  4. 56
      src/store/websites/cert.ts

27
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 (
<ListPageLayout
childrenClassName={styles.applyContent}

11
src/routes.tsx

@ -12,6 +12,7 @@ import EmptyLayout from '@/layout/EmptyLayout.tsx'
import { Route as LoginRouteImport } from '@/pages/login'
import { generateUUID } from '@/utils/uuid.ts'
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
import Login2 from '@/pages/login2/index.tsx'
import {
AnyRoute,
createRootRouteWithContext,
@ -108,6 +109,7 @@ const loginRoute = LoginRouteImport.update({
getParentRoute: () => 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,

8
src/service/websites.ts

@ -23,17 +23,21 @@ const websitesServ = {
renewCertificate: async (params: any) => {
return request.post<any, any>("/website/cert/renew_certificate", params);
},
// 删除证书
deletesCertificate: async (params: any) => {
return request.post<any, any>("/cert/apply/deletes", params);
},
// 添加记录
addCnameCertificate: async (params: any) => {
return request.post<any, any>("/cert/apply/add/cname", params);
},
// 下载证书
downloadCertificate: async (params: any) => {
return request.post<any, any>("/website/cert/download_certificate", params);
return request.post<any, any>("/cert/apply/download", params);
},
// 获取证书申请日志
getCertificateLogs: async (params: any) => {
return request.get<any, any>("/website/cert/get_certificate_logs", { params });
return request.post<any, any>("/cert/log", params);
},
applyTxtCertificate: async (params: any) => {
return request.post<any, any>("/cert/apply/resolve", params);

56
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<IApiResult, ICertificate>(() =>
});
export const applyTxtCertificateAtom = atomWithMutation<IApiResult, Req_ApplyTxtCertificate>(() => {
// status 3:进行中,5:失败,9:成功
return {
mutationKey: ["applyTxtCertificate"],
mutationFn: async (data: Req_ApplyTxtCertificate) => {
@ -164,6 +183,43 @@ export const applyTxtCertificateAtom = atomWithMutation<IApiResult, Req_ApplyTxt
};
});
export const getCertificateLogsAtom = (data: req_CertLogs) =>
atomWithQuery<IApiResult, any>(() => {
return {
queryKey: ["getCertificateLogs"],
queryFn: async () => {
return await websitesServ.cert.getCertificateLogs(data);
},
select: (res) => {
return res.data;
},
};
});
export const downloadCertificateAtom = (params: Req_DownloadCert) =>
atomWithQuery<IApiResult, any>(() => {
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<IApiResult, any>(() => {
return {
queryKey: ["deletesCertificate", params],
queryFn: async ({ queryKey: [, params] }) => {
return await websitesServ.cert.deletesCertificate(params);
},
select: (res) => {
return res.data;
},
};
});
//==================================================================================================================================================kelis
// //certApple

Loading…
Cancel
Save