From 80f33e4cf60791fb39991eaceeb9c7ea515b6e22 Mon Sep 17 00:00:00 2001 From: lk Date: Wed, 11 Sep 2024 21:59:20 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E9=82=AE=E7=AE=B1=E7=99=BB?= =?UTF-8?q?=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/websites/cert/management.tsx | 590 +++++++++++++++++++++++++++++++++ 1 file changed, 590 insertions(+) create mode 100644 src/pages/websites/cert/management.tsx diff --git a/src/pages/websites/cert/management.tsx b/src/pages/websites/cert/management.tsx new file mode 100644 index 0000000..5780886 --- /dev/null +++ b/src/pages/websites/cert/management.tsx @@ -0,0 +1,590 @@ +import React, { useEffect, useMemo, useState } from "react"; +import { + Table, + Input, + Button, + Tag, + Progress, + Space, + Drawer, + Typography, + Form, + DatePicker, + Tooltip, + Modal, + ProgressProps, +} from "antd"; +import { CheckCircleFilled, CheckCircleOutlined, CopyOutlined, SearchOutlined } from "@ant-design/icons"; +import { t } from "@/i18n.ts"; +import ListPageLayout from "@/layout/ListPageLayout.tsx"; +import TextArea from "antd/es/input/TextArea"; +import { useNavigate } from "@tanstack/react-router"; +import { + certListAtom, + checkDomainAtom, + deletesCertificateAtom, + downloadCertificateAtom, + editCertificateAtom, + getCertificateLogsAtom, + Req_CertList, + req_CertLogs, + Req_DeletesCert, + Req_DownloadCert, + Req_UpdateCert, + saveOrUpdateCertAtom, +} from "@/store/websites/cert.ts"; +import { useAtomValue } from "jotai/index"; +import { format } from "date-fns"; +import websitesServ from "@/service/websites.ts"; +import { useAtom } from "jotai"; +import { getToken } from "@/store/system.ts"; + +const { confirm } = Modal; +const { Text, Link } = Typography; +const i18nPrefix = "cert.management"; + +const CertApplyingDrawer = (props: { id: number; onCloseApplyingDrawer; applyingDrawerVisible }) => { + const [dData, setDdata] = useState({ + log_id: props.id, + log_type: "cert_apply", + websocket: false, + log_pos: 0, + // 根据实际数据结构添加其他属性的初始值 + }); + const [showTextInfo, setShowTextInfo] = useState(""); + const [onChangeDT, setOnChangeDT] = useState(0); + const { data: certLogsData, isFetching: certLogsFetching } = useAtomValue( + useMemo(() => getCertificateLogsAtom(dData), [onChangeDT]), + ); + + useEffect(() => { + if (certLogsData && (certLogsData as any)?.log) { + setShowTextInfo((prev) => prev + (certLogsData as any).log.toString()); + } + }, [certLogsData]); + + useEffect(() => { + if (props.applyingDrawerVisible) { + setShowTextInfo(""); + setOnChangeDT((prev) => prev + 1); + } + let timer: number | undefined; + if (props.applyingDrawerVisible) { + timer = window.setInterval(() => { + setDdata((prevState) => ({ + ...prevState, + log_id: props.id, + log_pos: (certLogsData as any)?.log_pos || 0, + })); + // console.log("update drawer"); + setOnChangeDT((prev) => prev + 1); + }, 5000); + } else { + setDdata((prevState) => ({ + ...prevState, + log_id: props.id, + log_pos: 0, + })); + window.clearInterval(timer); + } + + return () => window.clearInterval(timer); + }, [props.applyingDrawerVisible]); + + return ( + +