From e23d1051e9211b15c76847762aae7dd11bf8d5f8 Mon Sep 17 00:00:00 2001 From: lk Date: Thu, 5 Sep 2024 22:32:32 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=AF=81=E4=B9=A6=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=E7=94=B3=E8=AF=B7=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 70 ++++----- src/App.css | 14 +- src/layout/RootLayout.tsx | 2 +- src/pages/websites/cert/apply.tsx | 273 +++++++++++++++++++++++------------ src/service/websites.ts | 33 +++-- src/store/websites/cert.ts | 295 +++++++++++++++++++++----------------- vite.config.ts | 1 + 7 files changed, 414 insertions(+), 274 deletions(-) diff --git a/package.json b/package.json index 3bac782..c7b048c 100644 --- a/package.json +++ b/package.json @@ -12,58 +12,58 @@ }, "dependencies": { "@ant-design/cssinjs": "^1.21.1", - "@ant-design/icons": "^5.3.6", - "@ant-design/pro-components": "^2.7.0", + "@ant-design/icons": "^5.4.0", + "@ant-design/pro-components": "^2.7.15", "@ant-design/pro-layout": "^7.19.12", "@ant-design/pro-provider": "^2.14.9", - "@formily/antd-v5": "^1.2.0", - "@formily/core": "^2.3.1", - "@formily/react": "^2.3.1", + "@formily/antd-v5": "^1.2.3", + "@formily/core": "^2.3.2", + "@formily/react": "^2.3.2", "@icon-park/react": "^1.4.2", "@melloware/react-logviewer": "^5.2.0", - "@tanstack/query-core": "^5.52.0", - "@tanstack/react-query": "^5.52.1", - "@tanstack/react-router": "^1.50.0", - "antd": "^5.16.1", + "@tanstack/query-core": "^5.54.1", + "@tanstack/react-query": "^5.54.1", + "@tanstack/react-router": "^1.53.1", + "antd": "^5.20.5", "antd-style": "^3.6.2", - "axios": "^1.6.8", - "bunshi": "^2.1.4", - "dayjs": "^1.11.10", + "axios": "^1.7.7", + "bunshi": "^2.1.5", + "dayjs": "^1.11.13", "fast-copy": "^3.0.2", "fast-deep-equal": "^3.1.3", - "i18next": "^23.11.2", + "i18next": "^23.14.0", "i18next-browser-languagedetector": "^7.2.1", - "jotai": "^2.8.0", + "jotai": "^2.9.3", "jotai-devtools": "^0.9.1", - "jotai-scope": "^0.5.1", - "jotai-tanstack-query": "^0.8.5", + "jotai-scope": "^0.5.2", + "jotai-tanstack-query": "^0.8.7", "lodash": "^4.17.21", - "re-resizable": "^6.9.11", - "react": "^18.2.0", - "react-dom": "^18.2.0", - "react-i18next": "^14.1.0", + "re-resizable": "^6.9.17", + "react": "^18.3.1", + "react-dom": "^18.3.1", + "react-i18next": "^14.1.3", "react-if": "^4.1.5", "react-layout-kit": "^1.9.0", - "react-rnd": "^10.4.2-test2", - "react-use": "^17.5.0", - "throttle-debounce": "^5.0.0", + "react-rnd": "^10.4.12", + "react-use": "^17.5.1", + "throttle-debounce": "^5.0.2", "use-merge-value": "^1.2.0", "wonka": "^6.3.4" }, "devDependencies": { - "@tanstack/router-devtools": "^1.26.20", - "@tanstack/router-vite-plugin": "^1.26.16", - "@types/react": "^18.2.66", - "@types/react-dom": "^18.2.22", - "@typescript-eslint/eslint-plugin": "^7.2.0", - "@typescript-eslint/parser": "^7.2.0", - "@vitejs/plugin-react": "^4.2.1", + "@tanstack/router-devtools": "^1.53.1", + "@tanstack/router-vite-plugin": "^1.54.0", + "@types/react": "^18.3.5", + "@types/react-dom": "^18.3.0", + "@typescript-eslint/eslint-plugin": "^7.18.0", + "@typescript-eslint/parser": "^7.18.0", + "@vitejs/plugin-react": "^4.3.1", "eslint": "^8.57.0", - "eslint-plugin-react-hooks": "^4.6.0", - "eslint-plugin-react-refresh": "^0.4.6", + "eslint-plugin-react-hooks": "^4.6.2", + "eslint-plugin-react-refresh": "^0.4.11", "mockjs": "^1.1.0", - "typescript": "^5.2.2", - "vite": "^5.2.0", - "vite-plugin-mock": "^3.0.1" + "typescript": "^5.5.4", + "vite": "^5.4.3", + "vite-plugin-mock": "^3.0.2" } } diff --git a/src/App.css b/src/App.css index f457a94..7edb8e1 100644 --- a/src/App.css +++ b/src/App.css @@ -7,12 +7,10 @@ display: inherit; line-height: 28px; } - } .top-breadcrumb { .item { - display: flex; align-items: center; justify-content: center; @@ -28,7 +26,6 @@ cursor: pointer; &:hover { - color: #1c7ed6; } } @@ -50,16 +47,19 @@ color: green; } -.color-green1{ - color: rgb(18 185 128 / 1 ); +.color-green1 { + color: rgb(18 185 128 / 1); +} +.color-blue { + color: #1c7ed6; } .color-red { - color: #F56C6C; + color: #f56c6c; } .color-yellow { - color: rgb(250 145 0) + color: rgb(250 145 0); } .text-bold { diff --git a/src/layout/RootLayout.tsx b/src/layout/RootLayout.tsx index 09f60ae..04c9ad1 100644 --- a/src/layout/RootLayout.tsx +++ b/src/layout/RootLayout.tsx @@ -127,7 +127,7 @@ export default () => { color: '#00000012', size: 17, }, - zIndex: 1009, + zindex: 1009, } as any } style={{ width: '100vw', height: '100vh' }}> { +const BrandSelect = (props: { value: string; applyTxtCertificateData; setApplyTxtCertificateData }) => { const { styles, cx } = useStyle(); - const [value, setValue] = useState(() => props.value); useEffect(() => { - setValue(props.value); + onChange(props.value); }, [props.value]); const onChange = useCallback((val: string) => { - props.onChange?.(val); + props.setApplyTxtCertificateData((prevState) => ({ + ...prevState, + acme_type: val, + })); }, []); return ( @@ -40,7 +49,7 @@ const BrandSelect = (props: any) => { vertical={true} onClick={() => onChange("Google")} className={cx("band-normal", { - "band-active": value === "Google" || !props.value, + "band-active": props.applyTxtCertificateData.acme_type === "Google" || !props.value, })} > @@ -50,7 +59,7 @@ const BrandSelect = (props: any) => { vertical={true} onClick={() => onChange("ZeroSSL")} className={cx("band-normal", { - "band-active": value === "ZeroSSL", + "band-active": props.applyTxtCertificateData.acme_type === "ZeroSSL", })} > @@ -60,7 +69,7 @@ const BrandSelect = (props: any) => { vertical={true} onClick={() => onChange("Let's Encrypt")} className={cx("band-normal", { - "band-active": value === "Let's Encrypt", + "band-active": props.applyTxtCertificateData.acme_type === "Let's Encrypt", })} > @@ -71,27 +80,40 @@ const BrandSelect = (props: any) => { ); }; -const StatusTable = (props: { value: string }) => { - const [data, setData] = useState(null); // 临时状态来存储模拟数据 - const { isFetching } = useAtomValue(useMemo(() => dnsConfigAtom(props.value), [props.value])); - - const { - data: dnsVerifyStatus, - isFetching: isVerifyFetching, - refetch, - } = useAtomValue(useMemo(() => dnsVerifyAtom(props.value, isFetching), [props.value, isFetching])); +const StatusTable = (props: { value: string; setCurrentStep; setApplyTxtCertificateData }) => { + // const [data, setData] = useState(null); // 临时状态来存储模拟数据 + const [forceUpdate, setForceUpdate] = useState(0); + const { data, isFetching: isVerifyFetching } = useAtomValue( + useMemo(() => checkDomainAtom(props.value, forceUpdate === 0), [props.value, forceUpdate]), + ); + const refetch = () => { + setForceUpdate((prev) => prev + 1); + }; - const setDnsVerifyOK = useSetAtom(dnsVerifyOKAtom); + const { mutate: addCnameFun, isPending: addCnamePending, isSuccess } = useAtomValue(certAddCnameAtom); + const handleAddCname = async (info: any) => { + addCnameFun(info); + }; + // const { + // data: dnsVerifyStatus, + // isFetching: isVerifyFetching, + // refetch, + // } = useAtomValue(useMemo(() => dnsVerifyAtom(props.value, isFetching), [props.value, isFetching])); + // + // const setDnsVerifyOK = useSetAtom(dnsVerifyOKAtom); const timerRef = useRef(); - const handleCopy = (str:string) => { - navigator.clipboard.writeText(str).then(() => { - message.info('复制成功!'); - }).catch(err => { + const handleCopy = (str: string) => { + navigator.clipboard + .writeText(str) + .then(() => { + message.info("复制成功!"); + }) + .catch((err) => { message.info(err); }); - }; + }; const columns = useMemo(() => { return [ @@ -105,27 +127,61 @@ const StatusTable = (props: { value: string }) => { ), dataIndex: "status", - width: 100, + width: 150, render: (_, record) => { - if (isFetching) { - return {t(`${i18nPrefix}.actions.dnsVerifyStatus.0`, "等待")}; - } - - if (isVerifyFetching) { - //0,等待 1,域名OK,2,域名分析错误,3:检测中 4:检测成功,匹配失败 5:检测失败,9:检测成功 - return ( - - - {t(`${i18nPrefix}.actions.dnsVerifyStatus.3`, "检测中")} - - ); - } const dns = record.dns_name; - const info = (dnsVerifyStatus as any)?.find((item) => item.dns_name === dns) as any; + const info = (data as any)?.dns_list?.find((item) => item.dns_name === dns) as any; if (info) { - return {t(`${i18nPrefix}.actions.dnsVerifyStatus.${info.status}`, `${info?.status_txt}`)}; + if (info.is_self === true) { + return ( + // + { + handleAddCname(info); + }} + > + + 自动注册 + + ); + } else { + if (isVerifyFetching) { + //0,等待 1,域名OK,2,域名分析错误,3:检测中 4:检测成功,匹配失败 5:检测失败,9:检测成功 + return ( + + + {t(`${i18nPrefix}.actions.dnsVerifyStatus.3`, "检测中")} + + ); + } + //0,等待 1,域名OK,2,域名分析错误,3:检测中 4:检测成功,匹配失败 5:检测失败,9:检测成功 + return ( + + {t(`${i18nPrefix}.actions.dnsVerifyStatus.${info.status}`, `${info?.status_txt}`)} + + ); + } } - return {t(`${i18nPrefix}.actions.dnsVerifyStatus.0`, "等待")}; + return ( + + {t(`${i18nPrefix}.actions.dnsVerifyStatus.0`, "等待")} + + ); }, }, { @@ -147,7 +203,14 @@ const StatusTable = (props: { value: string }) => { width: 200, render(text) { return ( - ); @@ -178,42 +241,31 @@ const StatusTable = (props: { value: string }) => { width: 200, render: (text) => { return ( - ); }, }, ] as ColumnsType; - }, [isFetching, isVerifyFetching, dnsVerifyStatus]); + }, [isVerifyFetching, data]); useEffect(() => { // 模拟数据 - const mockData = { - dns_list: [ - { - status: 1, - name_servers: "Example NS", - dns_name: "example.com", - host: "example", - type: "A", - record_value: "192.168.1.1", - }, - { - status: 3, - name_servers: "Another NS", - dns_name: "another.com", - host: "another", - type: "CNAME", - record_value: "cname.another.com", - }, - ], - }; - - setData(mockData); - if ((dnsVerifyStatus as any)?.every((item) => item.status === 9)) { - setDnsVerifyOK(true); + if ((data as any)?.check_ok === true) { + props.setCurrentStep(2); + props.setApplyTxtCertificateData((prevState) => ({ + ...prevState, + dns_list: (data as any).dns_list, + })); return; } @@ -222,8 +274,15 @@ const StatusTable = (props: { value: string }) => { return; } // dnsVerifyStatus 如果所有status 为 9 则说明域名验证通过 - if ((dnsVerifyStatus as any)?.every((item) => item.status === 9)) { - setDnsVerifyOK(true); + // if ((data as any)?.dns_list?.every((item) => item.status === 9)) { + // props.setCurrentStep(2); + // window.clearInterval(timerRef.current); + if ((data as any)?.check_ok === true) { + props.setCurrentStep(2); + props.setApplyTxtCertificateData((prevState) => ({ + ...prevState, + dns_list: (data as any).dns_list, + })); window.clearInterval(timerRef.current); } else { refetch(); @@ -233,7 +292,7 @@ const StatusTable = (props: { value: string }) => { return () => { window.clearInterval(timerRef.current); }; - }, [dnsVerifyStatus, isVerifyFetching]); + }, [data, isVerifyFetching]); return ( <> @@ -248,7 +307,7 @@ const StatusTable = (props: { value: string }) => { { + props.setDomains(e.target.value); + }} /> )} {props.currentDomainMod === "multiple" && ( @@ -300,11 +362,30 @@ const domainsAtom = atomWithStorage("domains", ""); const Apply = () => { const { styles } = useStyle(); const [form] = Form.useForm(); - const { mutate: saveOrUpdate, isPending: isSubmitting } = useAtomValue(saveOrUpdateCertAtom); + const { + mutate: applyTxtCertificateFun, + isPending: applyTxtCertificatePending, + isSuccess: applyTxtCertificateIsSuccess, + } = useAtomValue(applyTxtCertificateAtom); const [domains, setDomains] = useAtom(domainsAtom); const [currentStep, setCurrentStep] = useState(0); const [currentDomainMod, setCurrentDomainMod] = useState<"single" | "multiple">("single"); - const dnsVerifyOK = useAtomValue(dnsVerifyOKAtom); + + const [applyTxtCertificateData, setApplyTxtCertificateData] = useState({ + is_sync: true, + acme_type: "", + key_rsa: "", + dns_list: [], + }); + const handleAlgorithmChange = (value: string) => { + setApplyTxtCertificateData((prevState) => ({ + ...prevState, + key_rsa: value, + })); + }; + const applyTxtCertificateClick = () => { + applyTxtCertificateFun(applyTxtCertificateData); + }; useEffect(() => { if (domains) { @@ -313,7 +394,6 @@ const Apply = () => { }); } }, [domains]); - return ( { } }} onFinish={async (values) => { - if (dnsVerifyOK) { - saveOrUpdate(values); - } + // if (dnsVerifyOK) { + // saveOrUpdate(values); + // } }} > {/* { label={t(`${i18nPrefix}.columns.type`, "域名验证")} rules={[{ required: true, message: t(`${i18nPrefix}.columns.type`, "域名验证没有通过") }]} > - + { }, ]} > - + { }, ]} > - @@ -420,19 +508,24 @@ const Apply = () => { {currentStep !== 0 && ( - )} {currentStep === 0 && ( - )} {currentStep !== 0 && ( - )} diff --git a/src/service/websites.ts b/src/service/websites.ts index aff0817..0294812 100644 --- a/src/service/websites.ts +++ b/src/service/websites.ts @@ -7,19 +7,32 @@ import { IWebsiteDnsAccount } from '@/types/website/dns_account' const websitesServ = { cert: { - ...createCURD('/website/cert'), - //dns_config - dnsConfig: async (params: any) => { - return request.post('/website/cert/dns_config', params) + + ...createCURD("/website/cert"), + // 发起域名检测 + checkDomain: async (params: any) => { + return request.post("/cert/apply/dns_config", params); + }, + // 证书续签 + renewCertificate: async (params: any) => { + return request.post("/website/cert/renew_certificate", params); + }, + // 添加记录 + addCnameCertificate: async (params: any) => { + return request.post("/cert/apply/add/cname", params); }, - //dns_verify - dnsVerify: async (params: any) => { - return request.post('/website/cert/dns_verify', params) + // 下载证书 + downloadCertificate: async (params: any) => { + return request.post("/website/cert/download_certificate", params); }, - //cert-apply - certApply: async (params: any) => { - return request.post('/website/cert/dns_verify', params) + // 获取证书申请日志 + getCertificateLogs: async (params: any) => { + return request.get("/website/cert/get_certificate_logs", { params }); }, + applyTxtCertificate: async (params: any) => { + return request.post("/cert/apply/resolve", params); + }, + }, ssl: { diff --git a/src/store/websites/cert.ts b/src/store/websites/cert.ts index a1f9038..b4d174f 100644 --- a/src/store/websites/cert.ts +++ b/src/store/websites/cert.ts @@ -1,185 +1,218 @@ -import { atom } from 'jotai' -import { IApiResult, IPage } from '@/global' -import { atomWithMutation, atomWithQuery, queryClientAtom } from 'jotai-tanstack-query' -import { message } from 'antd' -import { t } from 'i18next' -import websitesServ from '@/service/websites.ts' - - -type SearchParams = IPage & { - name?: string -} +import { atom } from "jotai"; +import { IApiResult, IPage } from "@/global"; +import { atomWithMutation, atomWithQuery, queryClientAtom } from "jotai-tanstack-query"; +import { message } from "antd"; +import { t } from "i18next"; +import websitesServ from "@/service/websites.ts"; + +export type Req_SearchParams = IPage & { + name?: string; +}; + +export type Req_AddCname = { + is_sync: boolean; + dns_list: ICertificate[]; +}; + +export type Req_ApplyTxtCertificate = { + is_sync: boolean; + acme_type: string; + key_rsa: string; + dns_list: ICertificate[]; +}; export const bandTypes = [ - { label: 'Google', value: 'Google' }, - { label: 'ZeroSSL', value: 'ZeroSSL' }, - { label: 'Let\'s Encrypt', value: 'Let\'s Encrypt' }, -] + { label: "Google", value: "Google" }, + { label: "ZeroSSL", value: "ZeroSSL" }, + { label: "Let's Encrypt", value: "Let's Encrypt" }, +]; export const algorithmTypes = [ - { label: 'RSA', value: 'RSA' }, - { label: 'ECC', value: 'ECC' }, -] - + { label: "RSA", value: "RSA" }, + { label: "ECC", value: "ECC" }, +]; export const StatusText = { - 1: [ '已签发', 'green' ], - 2: [ '申请中', 'default' ], - 3: [ '申请失败', 'red' ] -} + 1: ["已签发", "green"], + 2: ["申请中", "default"], + 3: ["申请失败", "red"], +}; +export const certIdAtom = atom(0); -export const certIdAtom = atom(0) +export const certIdsAtom = atom([]); -export const certIdsAtom = atom([]) +export const certAtom = atom(undefined as unknown as ICertificate); -export const certAtom = atom(undefined as unknown as ICertificate) - -export const certSearchAtom = atom({ +export const certSearchAtom = atom({ // key: '', pageSize: 10, page: 1, -} as SearchParams) +} as Req_SearchParams); export const certPageAtom = atom({ pageSize: 10, page: 1, -}) +}); + +//=================================================================================================================================================kelis +export const checkDomainAtom = (domains: string, isClear: boolean) => + atomWithQuery(() => { + return { + enabled: domains.length > 0 && domains.includes("."), + queryKey: ["checkDomain", domains], + queryFn: async ({ queryKey: [, domains] }) => { + if ((domains as string).length === 0) { + return Promise.reject({ + data: [], + }); + } -//certApple -export const certAppleCertAtom = atomWithMutation((get) => { + return await websitesServ.cert.checkDomain({ + dns_full_list: domains, + parse: true, + is_clear: isClear, + }); + }, + select: (res) => { + return res.data; + }, + }; + }); + +export const certListAtom = atomWithQuery((get) => { + return { + queryKey: ["certList", get(certSearchAtom)], + queryFn: async ({ queryKey: [, params] }) => { + return await websitesServ.cert.list(params as Req_SearchParams); + }, + select: (res) => { + const data = res.data; + data.rows = data.rows?.map((row) => { + return { + ...row, + //status: convertToBool(row.status) + }; + }); + return data; + }, + }; +}); +export const certAddCnameAtom = atomWithMutation(() => { return { - mutationKey: [ 'appleCert' ], + mutationKey: ["certAddCname"], mutationFn: async (data) => { - //data.status = data.status ? '1' : '0' - return await websitesServ.cert.certApply(data) + const dData: Req_AddCname = { + is_sync: true, + dns_list: [data], + }; + return await websitesServ.cert.addCnameCertificate(dData); }, onSuccess: (res) => { - const isAdd = !!res.data?.id - message.success(t(isAdd ? 'message.saveSuccess' : 'message.editSuccess', '保存成功')) - - //更新列表 - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // @ts-ignore fix - get(queryClientAtom).invalidateQueries({ queryKey: [ 'certs', get(certSearchAtom) ] }) - - return res - } - } -}) - + const status = res.data?.item[0]?.status || 0; + const status_txt = res.data?.item[0]?.status_txt; + if (status || status === 5) { + message.error(status_txt); + } else { + message.success(status_txt); + } + return res; + }, + }; +}); +export const applyTxtCertificateAtom = atomWithMutation(() => { + return { + mutationKey: ["applyTxtCertificate"], + mutationFn: async (data: Req_ApplyTxtCertificate) => { + return await websitesServ.cert.applyTxtCertificate(data); + }, + onSuccess: (res) => { + return res; + }, + }; +}); + +//==================================================================================================================================================kelis + +// //certApple +// export const certAppleCertAtom = atomWithMutation((get) => { +// return { +// mutationKey: ["appleCert"], +// mutationFn: async (data) => { +// //data.status = data.status ? '1' : '0' +// return await websitesServ.cert.certApply(data); +// }, +// onSuccess: (res) => { +// const isAdd = !!res.data?.id; +// message.success(t(isAdd ? "message.saveSuccess" : "message.editSuccess", "保存成功")); +// +// //更新列表 +// // eslint-disable-next-line @typescript-eslint/ban-ts-comment +// // @ts-ignore fix +// get(queryClientAtom).invalidateQueries({ queryKey: ["certs", get(certSearchAtom)] }); +// +// return res; +// }, +// }; +// }); export const certsAtom = atomWithQuery((get) => { return { - queryKey: [ 'certs', get(certSearchAtom) ], - queryFn: async ({ queryKey: [ , params ] }) => { - return await websitesServ.cert.list(params as SearchParams) + queryKey: ["certs", get(certSearchAtom)], + queryFn: async ({ queryKey: [, params] }) => { + return await websitesServ.cert.list(params as Req_SearchParams); }, - select: res => { - const data = res.data - data.rows = data.rows?.map(row => { + select: (res) => { + const data = res.data; + data.rows = data.rows?.map((row) => { return { ...row, //status: convertToBool(row.status) - } - }) - return data - } - } -}) + }; + }); + return data; + }, + }; +}); //saveOrUpdateAtom export const saveOrUpdateCertAtom = atomWithMutation((get) => { - return { - mutationKey: [ 'updateCert' ], + mutationKey: ["updateCert"], mutationFn: async (data) => { //data.status = data.status ? '1' : '0' if (data.id) { - return await websitesServ.cert.update(data) + return await websitesServ.cert.update(data); } - return await websitesServ.cert.add(data) + return await websitesServ.cert.add(data); }, onSuccess: (res) => { - const isAdd = !!res.data?.id - message.success(t(isAdd ? 'message.saveSuccess' : 'message.editSuccess', '保存成功')) + const isAdd = !!res.data?.id; + message.success(t(isAdd ? "message.saveSuccess" : "message.editSuccess", "保存成功")); //更新列表 // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore fix - get(queryClientAtom).invalidateQueries({ queryKey: [ 'certs', get(certSearchAtom) ] }) + get(queryClientAtom).invalidateQueries({ queryKey: ["certs", get(certSearchAtom)] }); - return res - } - } -}) + return res; + }, + }; +}); export const deleteCertAtom = atomWithMutation((get) => { return { - mutationKey: [ 'deleteCert' ], + mutationKey: ["deleteCert"], mutationFn: async (ids: number[]) => { - return await websitesServ.cert.batchDelete(ids ?? get(certIdsAtom)) + return await websitesServ.cert.batchDelete(ids ?? get(certIdsAtom)); }, onSuccess: (res) => { - message.success('message.deleteSuccess') + message.success("message.deleteSuccess"); //更新列表 - get(queryClientAtom).invalidateQueries({ queryKey: [ 'certs', get(certSearchAtom) ] }) - return res - } - } -}) - -//dnsConfig -export const dnsConfigAtom = (domains: string) => atomWithQuery(() => { - - return { - enabled: domains.length > 0 && domains.includes('.'), - queryKey: [ 'dnsConfig', domains ], - queryFn: async ({ queryKey: [ , domains ] }) => { - - if ((domains as string).length === 0) { - return Promise.reject({ - data: [] - }) - } - - return await websitesServ.cert.dnsConfig({ - dns_full_list: domains, - parse: (domains as string)?.includes('*') - }) - }, - select: res => { - return res.data - } - } -}) - -export const dnsVerifyOKAtom = atom(false) - -//query dnsVerify -export const dnsVerifyAtom = (domains: string, block: boolean) => atomWithQuery(() => { - - return { - enabled: !block && domains.length > 0 && domains.includes('.'), - queryKey: [ 'dnsVerify', domains ], - queryFn: async ({ queryKey: [ , domains ] }) => { - - if ((domains as string).length === 0) { - return Promise.reject({ - data: [] - }) - } - - return await websitesServ.cert.dnsVerify({ - dns_list: domains, - }) + get(queryClientAtom).invalidateQueries({ queryKey: ["certs", get(certSearchAtom)] }); + return res; }, - select: res => { - return res.data?.dns_list - } - } -}) - - + }; +}); diff --git a/vite.config.ts b/vite.config.ts index 75bb7c0..5a9c23e 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -13,6 +13,7 @@ const proxyMap = { '/api/v1/movie': 'http://47.113.117.106:10000', //'/api/v1/certold': 'http://192.168.31.41:8000', '/api/v1/cert': 'http://127.0.0.1:8000', + //'/api/v1/cert': 'http://192.168.31.41:8000', } as Record const proxyConfig = Object.keys(proxyMap).reduce((acc, key) => {