|
|
@ -1,11 +1,17 @@ |
|
|
|
import { useMemo, useState } from 'react' |
|
|
|
import { useEffect, useMemo, useState } from 'react' |
|
|
|
import { BetaSchemaForm, ProColumns, ProFormColumnsType, ProTable } from '@ant-design/pro-components' |
|
|
|
import { useTranslation } from '@/i18n.ts' |
|
|
|
import { AcmeAccountTypes, acmeListAtom, acmePageAtom, AcmeType, saveOrUpdateAcmeAtom } from '@/store/websites/acme.ts' |
|
|
|
import { |
|
|
|
AcmeAccountTypes, |
|
|
|
acmeListAtom, |
|
|
|
acmePageAtom, |
|
|
|
AcmeType, |
|
|
|
deleteAcmeAtom, |
|
|
|
saveOrUpdateAcmeAtom |
|
|
|
} from '@/store/websites/acme.ts' |
|
|
|
import { useAtom, useAtomValue } from 'jotai' |
|
|
|
import { Alert, Button, Form, Popconfirm } from 'antd' |
|
|
|
import { KeyTypeEnum, KeyTypes } from '@/store/websites/ssl.ts' |
|
|
|
import { deleteDNSAtom } from '@/store/websites/dns.ts' |
|
|
|
import { WebSite } from '@/types' |
|
|
|
|
|
|
|
const AcmeList = () => { |
|
|
@ -13,9 +19,9 @@ const AcmeList = () => { |
|
|
|
const { t } = useTranslation() |
|
|
|
const [ form ] = Form.useForm() |
|
|
|
const [ page, setPage ] = useAtom(acmePageAtom) |
|
|
|
const { data, isLoading, refetch } = useAtomValue(acmeListAtom) |
|
|
|
const { data, isLoading, isFetching, refetch } = useAtomValue(acmeListAtom) |
|
|
|
const { mutate: saveOrUpdate, isPending: isSubmitting, isSuccess } = useAtomValue(saveOrUpdateAcmeAtom) |
|
|
|
const { mutate: deleteDNS, isPending: isDeleting } = useAtomValue(deleteDNSAtom) |
|
|
|
const { mutate: deleteAcme, isPending: isDeleting } = useAtomValue(deleteAcmeAtom) |
|
|
|
const [ open, setOpen ] = useState(false) |
|
|
|
|
|
|
|
const columns = useMemo<ProColumns<WebSite.IAcmeAccount>[]>(() => { |
|
|
@ -53,7 +59,7 @@ const AcmeList = () => { |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: t('website.ssl.acme.columns.keyType', '密钥算法'), |
|
|
|
dataIndex: 'keyType', |
|
|
|
dataIndex: 'key_type', |
|
|
|
valueType: 'select', |
|
|
|
fieldProps: { |
|
|
|
options: KeyTypes |
|
|
@ -71,15 +77,16 @@ const AcmeList = () => { |
|
|
|
ellipsis: true, // 文本溢出省略
|
|
|
|
hideInForm: true, |
|
|
|
}, { |
|
|
|
title: '操作', |
|
|
|
title: t('website.ssl.acme.columns.option', '操作'), |
|
|
|
valueType: 'option', |
|
|
|
fixed: 'right', |
|
|
|
render: (_, record) => { |
|
|
|
return [ |
|
|
|
<Popconfirm |
|
|
|
key={'del_confirm'} |
|
|
|
disabled={isDeleting} |
|
|
|
onConfirm={() => { |
|
|
|
deleteDNS(record.id) |
|
|
|
deleteAcme(record.id) |
|
|
|
}} |
|
|
|
title={t('message.deleteConfirm')}> |
|
|
|
<a key="del"> |
|
|
@ -92,6 +99,12 @@ const AcmeList = () => { |
|
|
|
] |
|
|
|
}, []) |
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
if (isSuccess) { |
|
|
|
setOpen(false) |
|
|
|
} |
|
|
|
}, [ isSuccess ]) |
|
|
|
|
|
|
|
return ( |
|
|
|
<> |
|
|
|
<Alert message={t('website.ssl.acme.tip', 'Acme账户用于申请免费证书')}/> |
|
|
@ -114,7 +127,7 @@ const AcmeList = () => { |
|
|
|
}} |
|
|
|
type={'primary'}>{t('website.ssl.acme.add', '添加Acme帐户')}</Button> |
|
|
|
} |
|
|
|
loading={isLoading} |
|
|
|
loading={isLoading || isFetching} |
|
|
|
dataSource={data?.rows ?? []} |
|
|
|
columns={columns} |
|
|
|
search={false} |
|
|
@ -161,7 +174,7 @@ const AcmeList = () => { |
|
|
|
onFinish={async (values) => { |
|
|
|
// console.log('values', values)
|
|
|
|
saveOrUpdate(values) |
|
|
|
return isSuccess |
|
|
|
|
|
|
|
}} |
|
|
|
columns={columns as ProFormColumnsType[]}/> |
|
|
|
</> |
|
|
|